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

Pages: 1-4041-

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.

Name: Anonymous 2012-01-08 10:19

time echo "for (0..100000000) { \$b = 3.14159265 / 1.161803399; }" | perl

real    0m6.201s
user    0m5.923s
sys    0m0.049s

Name: Anonymous 2012-01-08 10:25

>>38
UPDATE: I booted up Mac OS X and run the same executable with mono.

$ time mono benchmark.exe

real    0m0.204s
user    0m0.191s
sys    0m0.008s


Therefore we can conclude C# and CLR is superior to all your shitty languages.

Name: Anonymous 2012-01-08 10:26

>>42
It optimized it out. What you timed is the time it takes for the VM to load.

Name: Anonymous 2012-01-08 10:30

check 'em

Name: Anonymous 2012-01-08 10:46

>>38-40 ps > cmd

Name: Anonymous 2012-01-08 10:50

>>42
$ time echo 'main(){ double b; int i; for (i = 0; i < 100000000; ++i) b = 3.14159265 / 1.161803399; }'| gcc -xc -O1 - && time ./a.out

real    0m0.065s
user    0m0.043s
sys    0m0.017s

real    0m0.073s
user    0m0.067s
sys    0m0.003s

Name: Anonymous 2012-01-08 10:56

>>46
C is shit.

Name: Anonymous 2012-01-08 11:11

>>47 shit's fasta!

Name: Anonymous 2012-01-08 11:16

>>48
shit's shit.

Name: Anonymous 2012-01-08 12:25

>>47-49
shit's shit
shit's fasta!
C is shit.

Lisp is shit.
Lisp's fasta!
C is Lisp.

Name: Anonymous 2012-01-08 12:41

this thread is retarded

Name: Anonymous 2012-01-08 13:00


* (defun l100 () (dotimes (i 100000000) (/ 3.14159265 1.161803399)))

L100
* (time (l100))

Evaluation took:
  0.160 seconds of real time
  0.160010 seconds of total run time (0.144009 user, 0.016001 system)
  100.00% CPU
  426,443,480 processor cycles
  0 bytes consed 

NIL

Name: Anonymous 2012-01-08 13:04

>>52
>100% CPU
Lol lisp is shit.

Name: Anonymous 2012-01-08 13:15

>>53
That's like saying Linux is shit because it uses 100% RAM.

Name: Anonymous 2012-01-08 13:27

>>53
Clearly we should restrict all benchmarks to a maximum of 10% cpu usage, that will give us the results we want.

Name: Anonymous 2012-01-08 13:29

>>53,54
TROLLED HARD!

Name: Anonymous 2012-01-08 13:32

>>56
You meant >>54,55. Don't fuck up again.

Name: Anonymous 2012-01-08 13:34

>>57
Your trolling is horrible, please try better next time /g/

Name: Anonymous 2012-01-08 13:39

>>58
u mad
/polecat kebabs/

Name: Anonymous 2012-01-08 15:37

>>36
[quote]Real code does not do things like this at all[/quote]

Have you ever used OpenGL? It's all floating point arithmetic, and benchmarking that is a true show of the speed of a language. Maybe OpenGL doesn't divide Pi by Phi millions of times, but it uses trigonometry like a bitch

Name: Anonymous 2012-01-08 15:41

>>60
Benchmarking OpenGL is a true show of the speed of a language
Who am I quoting.

Name: Anonymous 2012-01-08 15:54

/lolcat shebab/

Name: Anonymous 2012-01-08 15:56

This is retarded in many ways. A moderate precompiler would already calculate 3.14159265 / 1.161803399 etc.

Name: Anonymous 2012-01-08 16:01

>>60
You're braindamaged if you think that OpenGL does floating point divisions of two constants in a loop and nothing else. You can benchmark an OpenGL program that you port to multiple languages and see if you run into any differences. There already are implementations of things like glxgears in most languages with OpenGL bindings, so it's not like you would have to write any real code.
But if you think timing a million divisions in a loop is the same thing as benchmarking a whole OpenGL program, as if the entire doing graphics thing is non-important to the sight of floating point divisions (of constants), that would explain everything.

>>61
You're paraphrasing >>60.

Name: Anonymous 2012-01-08 17:10

>>64 bindings
aren't ports

Name: DUBS LIBERATION FRONT 2012-03-24 18:31

NON-DUBS SHALL BE CLEANSED FROM THE EARTH!

Name: Anonymous 2012-03-25 21:42

>>1
Fucking nice post! Badabababa I'm lovin' it!

Name: Anonymous 2012-03-26 18:59

>>51
All post-2011 threads on /prog/ are.

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