Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

hrtuhturht

Name: Anonymous 2012-01-07 19:05

Python:

time echo "for i in range(100000000): b = 3.14159265 / 1.161803399" | python

real    1m12.866s
user    1m11.549s
sys    0m0.160s


Ruby:

time echo "100000000.times do b = 3.14159265 / 1.161803399 end" | ruby

real    1m6.056s
user    1m5.952s
sys    0m0.047s


C:

benchmark.c:

int main(){
    double a;
    int x;
   
    for (x = 0; x < 100000000; x++)
    a  = 3.14159265 / 1.161803399;
}


Compilation:


time make benchmark
cc -ansi -pedantic -std=c1x  -lglut -lGLU -lrt  benchmark.c   -o benchmark

real    0m1.865s
user    0m0.240s
sys    0m0.073s


Run:

time ./benchmark

real    0m0.727s
user    0m0.630s
sys    0m0.007s


lol!

Name: Anonymous 2012-01-07 19:06

As if the difference in times isn't solely due to the echo program and piping.

Name: Anonymous 2012-01-07 19:07

>>1
The executable was even linked with OpenGL and glu due to my CFLAGS in that folder. Bloated C > Ruby > Python

Name: Anonymous 2012-01-07 19:09

>>1'
>-ansi ... -std=c1x
>-lglut
>-lGLU
>-lrt


wtf are you doing?

Name: Anonymous 2012-01-07 19:14

>>3
were you expecting interpreted languages to beat C native code?

Name: Anonymous 2012-01-07 19:40

>>5
No, but I wasn't expecting a difference like that
>>4
That was due yo a makefile I had set up for some opengl shit

Name: Anonymous 2012-01-07 19:49

>>2'
>implying piping isn't 2 file descriptors
>implying piping is slower than file I/O
time echo "100000000.times do b = 3.14159265 / 1.161803399 end"

real    0m0.000s
user    0m0.000s
sys    0m0.000s

Name: Anonymous 2012-01-07 19:50

>>6

Compare it with a JIT compiled(oh, yes, java) language. Do it OP.

Name: Anonymous 2012-01-07 20:11

Use the proper CFLAGS, OP. On my notebook.

$ time gcc -O3 -march=native -mtune=native -pipe -fomit-frame-pointer -funroll-loops -ffast-math -fforce-addr -msse -msse2 -msse3 -mmmx bench.c

real    0m0.070s
user    0m0.052s
sys    0m0.020s

$ time ./a.out

real    0m0.002s
user    0m0.000s
sys    0m0.000s

$ time echo "for i in range(100000000): b = 3.14159265 / 1.161803399" | python # crash incoming
Killed

real    0m37.495s
user    0m1.412s
sys    0m4.440s

Name: Anonymous 2012-01-07 20:11


[ Sat Jan 07 08:02:57 ]
[ @ ~/fhost/prog/java ] $ cat p.java
public class p
{
    public static void main(String args[])
    {
        double a;
        int i;
        for(i=0;i<100000000;++i){
            a = 3.14159265 / 1.161803399;
        }
    }
}
[ Sat Jan 07 08:03:02 ]
[ @ ~/fhost/prog/java ] $ javac p.java
[ Sat Jan 07 08:03:09 ]
[ @ ~/fhost/prog/java ] $ time java p

real    0m0.371s
user    0m0.184s
sys    0m0.176s
[ Sat Jan 07 08:03:33 ]
[ @ ~/fhost/prog/java ] $ time echo "for i in range(100000000): b = 3.14159265 / 1.161803399" | python

real    0m50.468s
user    0m43.071s
sys    0m7.392s
[ Sat Jan 07 08:10:14 ]
[ @ ~/fhost/prog/java ] $ cat p.c
int main() {
    double a;
    int x;
    for(x=0;x<100000000;x++)
        a = 3.14159265 / 1.161803399;
    return 0;
}
[ Sat Jan 07 08:10:18 ]
[ @ ~/fhost/prog/java ] $ gcc -S p.c
[ Sat Jan 07 08:10:21 ]
[ @ ~/fhost/prog/java ] $ gcc p.s
[ Sat Jan 07 08:10:24 ]
[ @ ~/fhost/prog/java ] $ time ./a.out

real    0m0.993s
user    0m0.952s
sys    0m0.016s
[ Sat Jan 07 08:10:29 ]
[ @ ~/fhost/prog/java ] $ cat p.s
    .file    "p.c"
    .text
.globl main
    .type    main, @function
main:
.LFB0:
    .cfi_startproc
    pushq    %rbp
    .cfi_def_cfa_offset 16
    movq    %rsp, %rbp
    .cfi_offset 6, -16
    .cfi_def_cfa_register 6
    movl    $0, -4(%rbp)
    jmp    .L2
.L3:
    movabsq    $4613271433301123154, %rax
    movq    %rax, -16(%rbp)
    addl    $1, -4(%rbp)
.L2:
    cmpl    $99999999, -4(%rbp)
    jle    .L3
    movl    $0, %eax
    leave
    ret
    .cfi_endproc
.LFE0:
    .size    main, .-main
    .ident    "GCC: (Debian 4.4.5-8) 4.4.5"
    .section    .note.GNU-stack,"",@progbits


I don't have ruby installed because im not a total faggot

Name: Anonymous 2012-01-07 20:12

>>9
-O3
congrats, gcc will optimize away the for loop,double a and int x since it does nothing and just return 0;

Name: Anonymous 2012-01-07 20:17

>>9
Gentoo ricer detected

Name: Anonymous 2012-01-07 20:18

I haven't posted in a while because escript is still running

Name: Anonymous 2012-01-07 20:33

Someone test this in Perl and Shell Script.

Name: Anonymous 2012-01-07 20:34

>>13
Still running

Name: Anonymous 2012-01-07 20:45

Get out of my /prog/, /g/ neckbeards.

Name: Anonymous 2012-01-07 20:49

benchmark.erl:

-module(benchmark).
-compile(export_all).

main(_)->
    iterate(0).

iterate(100000000)->
    ok;

iterate(X)->
    A = 3.14156265 / 1.61803399,
    iterate(X + 1).


run:
time escript benchmark.erl
benchmark.erl:10: Warning: variable 'A' is unused

real    37m0.894s
user    36m57.259s
sys    0m0.080s


Oh I am ashamed.

Name: Anonymous 2012-01-07 20:59

>>17
What the fuck. Wasn't Erlang supposed to be faster than Ruby and similar stuff?

Name: Anonymous 2012-01-07 21:02

>>18
It's fast as fuck in the virtual machine. But I don't know how to time it. It's almost C compilation fast

Name: Golang 2012-01-07 21:21

user@host ~/prog/go % echo -e 'package main\nfunc main(){var x int\nfor x = 0; x < 1e8; x++ {\n_ = 3.14159265 / 1.161803399\n}\n}'>benchmark.go&&time 8g benchmark.go&&time 8l -o benchmark benchmark.8&&time ./benchmark
8g benchmark.go  0.00s user 0.00s system 85% cpu 0.008 total
8l -o benchmark benchmark.8  0.08s user 0.01s system 99% cpu 0.092 total
./benchmark  0.73s user 0.00s system 99% cpu 0.732 total

Name: C for comparison 2012-01-07 21:25

>>20
user@host ~/prog/c % time echo 'int main(){double a;int x;for (x = 0; x < 100000000; x++)a  = 3.14159265 / 1.161803399;return 0;}'|gcc -xc -O0 -o benchmark - && time ./benchmark       
echo   0.00s user 0.00s system 48% cpu 0.002 total
gcc -xc -O0 -o benchmark -  0.08s user 0.04s system 84% cpu 0.136 total
./benchmark  0.67s user 0.00s system 99% cpu 0.672 total

Name: Anonymous 2012-01-07 21:31


% python -V
Python 2.7.2
% time echo "for i in range(100000000): b = 3.14159265 / 1.161803399" | python
python  15.62s user 1.24s system 98% cpu 17.030 total
time echo "for i in xrange(100000000): b = 3.14159265 / 1.161803399" | python
python  12.66s user 0.01s system 99% cpu 12.675 total
% ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
% time echo "100000000.times do b = 3.14159265 / 1.161803399 end" | ruby
ruby  25.98s user 4.03s system 99% cpu 30.013 total
% su -c 'eselect ruby set ruby19'
Password: s33crit
% ruby -v
ruby 1.9.3dev (2011-09-23 revision 33323) [x86_64-linux]
% time echo "100000000.times do b = 3.14159265 / 1.161803399 end" | ruby     
ruby  12.50s user 0.01s system 94% cpu 13.236 total
% python3 -V
Python 3.1.4
% time echo "for i in range(100000000): b = 3.14159265 / 1.161803399" | python3
python3  8.66s user 0.01s system 92% cpu 9.390 total
% php -d memory_limit=6G -r 'foreach (range(0, 100000000) as $i) $b = 3.14159265 / 1.161803399;'
PHP Fatal error:  Allowed memory size of 6442450944 bytes exhausted (tried to allocate 71 bytes) in Command line code on line 1
% time php -r 'for ($i = 0; $i < 100000000; ++$i) $b = 3.14159265 / 1.161803399;'
php 6.21s user 0.01s system 99% cpu 6.220 total
% cat tst.hs 
main = mapM_ (const $ 3.14159265 / 1.161803399 `seq` return ()) [1..100000000]
% time ghc -O2 -o tst tst.hs
[1 of 1] Compiling Main             ( tst.hs, tst.o )
Linking tst ...
ghc 0.40s user 0.14s system 8% cpu 6.755 total
% time ./tst
./tst  0.20s user 0.00s system 98% cpu 0.202 total
% node -v
v0.6.6
% # how does I make range in JS?
% time echo 'for (var i = 0; i < 100000000; ++i) var b = 3.14159265 / 1.161803399;'| node
node  0.18s user 0.00s system 99% cpu 0.188 total

Name: 22 2012-01-07 21:40

>>21 for comparison
% time echo 'int main(){double a;int x;for (x = 0; x < 100000000; x++)a  = 3.14159265 / 1.161803399;return 0;}'|gcc -xc -O0 -o benchmark - && time ./benchmark   
echo   0.00s user 0.00s system 0% cpu 0.001 total
gcc -xc -O0 -o benchmark -  0.01s user 0.01s system 71% cpu 0.028 total
./benchmark  0.22s user 0.00s system 99% cpu 0.221 total

Name: Anonymous 2012-01-07 22:24

$ time java | echo 


real    0m1.179s
user    0m0.320s
sys     0m0.130s
$

Name: Anonymous 2012-01-08 0:40

Pypy (JIT):

time echo "for i in range(100000000): b = 3.14159265 / 1.161803399" | pypy

real    0m6.200s
user    0m4.163s
sys    0m0.107s

Name: Anonymous 2012-01-08 0:41

>>25
Not even as fack as Erlang in VM mode, which is not JIT.

Name: Anonymous 2012-01-08 1:34

>>25
not even as fast as Java (JIT)

Name: Anonymous 2012-01-08 2:09

>>14
for (1 ..100000000) {
$b = 3.14159265 / 1.161803399;
}


time perl a.pl

real    0m7.169s
user    0m7.164s
sys    0m0.000s


I don't get what's the point. Not all of these are even run on the same machine.

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-08 3:16

What are you benchmarking? The divide should be optimized out of the loop since its constant.
The loop would be just incrementing an integer.

Name: Anonymous 2012-01-08 3:21

>>29
congrats on not reading the thread.

gcc optimizations will remove the loop and variables entirely and just return 0

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-08 3:36

>>30
In that case its even more retarded.

Name: Anonymous 2012-01-08 3:37

>>31
you know what's even more retarded? Thinking you're gonna get a good result when comparing native vs interpreted.

Now how about you go shit on someone elses thread you faggot

Name: Anonymous 2012-01-08 4:23

The point in benchmarking is I know native is faster than interpreter, but I want to know how much, and I also wanted to compare different interpreted languages. I found the results interesting and therefore posted them. I always thought Ruby was slower than python. SCIENCE

Name: Anonymous 2012-01-08 4:28

>>30
Then if C was merely looping, comparatively, Erlang is fast and I am proud

Name: Anonymous 2012-01-08 8:05

rofl, hahaahahahaha omfg wow gg loloolol wowwww omg lolllllll so fanny lol like 1 minute faster and how long does it take to read in comparison faggot?

Name: Anonymous 2012-01-08 8:22

>>33
If you really wanted to know how much you shouldn't be doing things like these because they are pointless. Real code does not do things like this at all, and there is a reason gcc's optimizations take away all the code (it's pointless and does nothing). Maybe try making a program that does real work and port it to other languages for comparison, if you really wanted to waste your time but do the ``Right Thing'' instead.
IHBT, because I replied.

>>34
I don't think you understand that the gcc optimization is referring to >>9.

Name: Anonymous 2012-01-08 8:37

GC is shit.

Name: Anonymous 2012-01-08 9:34


using System;

public class Benchmark
{
  public static void Main(string[] Args)
  {
    double a;
   
    for (int x = 0; x < 100000000; x++)
      a = 3.14159265 / 1.161803399;
  }
}

Results: (compiling just with a plain "csc benchmark.cs". And Windows has no "time" command, so I had to use Powershell)

PS C:\Users\me> Measure-Command {start-process benchmark.exe -Wait}


Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 0
Milliseconds      : 351
Ticks             : 3511530
TotalDays         : 4,06427083333333E-06
TotalHours        : 9,75425E-05
TotalMinutes      : 0,00585255
TotalSeconds      : 0,351153
TotalMilliseconds : 351,153


WHAT NOW, BITCHES?

Name: Anonymous 2012-01-08 9:36

>>38
Powershell is shit.

Name: Anonymous 2012-01-08 9:43

>>39
Everything is shit, just some things are less shit than others.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List