Re: [Pharo-users] [Stupid Benchmarks] C++ vs Pharo

2016-12-17 Thread Dimitris Chloupis
/ CLOCKS_PER_SEC; printf("time_spent=%f\n", time_spent); return (int)sum; } $ cc -O2 bench.c $ ./a.out time_spent=0.02 Who knows what optimisation was applied ? Maybe the loop wasn't executed at all ... (but I did add the return statement). >>> Best regards, >>> H

Re: [Pharo-users] [Stupid Benchmarks] C++ vs Pharo

2016-12-17 Thread Sven Van Caekenberghe
aybe the loop wasn't executed at all ... (but I did add the return statement). >>> Best regards, >>> Henrik >>> >>> -Original Message- >>> From: Pharo-users [mailto:pharo-users-boun...@lists.pharo.org] On Behalf Of >>> Sven Van Ca

Re: [Pharo-users] [Stupid Benchmarks] C++ vs Pharo

2016-12-17 Thread Sven Van Caekenberghe
begin) / CLOCKS_PER_SEC; printf("time_spent=%f\n", time_spent); } prometheus:tmp sven$ ./a.out time_spent=2.393986 >> Best regards, >> Henrik >> >> -Original Message- >> From: Pharo-users [mailto:pharo-users-boun...@lists.pharo.org] On Behalf Of

Re: [Pharo-users] [Stupid Benchmarks] C++ vs Pharo

2016-12-17 Thread Dimitris Chloupis
Yes I stand corrected, with unsigned ints and optimisations turned on the time for C++ for multiplication drops from 3.13 to 0.39 thats an almost 10 times speed up , with doubles and max optimisation on its 0.9 Yes I am using Pharo 32 bit. I think so, unless vmLatest now downloads Pharo 64 bit. S

Re: [Pharo-users] [Stupid Benchmarks] C++ vs Pharo

2016-12-17 Thread Sven Van Caekenberghe
December 17, 2016 2:15 PM > To: Any question about pharo is welcome > Subject: Re: [Pharo-users] [Stupid Benchmarks] C++ vs Pharo > > Like this: > > [ | sum | sum:= 0. 1 to: 1e9 do: [ :i | sum := sum + i ]. sum ] timeToRun. > > "0:00:00:39.305" > > ca

Re: [Pharo-users] [Stupid Benchmarks] C++ vs Pharo

2016-12-17 Thread Henrik Nergaard
- From: Pharo-users [mailto:pharo-users-boun...@lists.pharo.org] On Behalf Of Sven Van Caekenberghe Sent: Saturday, December 17, 2016 2:15 PM To: Any question about pharo is welcome Subject: Re: [Pharo-users] [Stupid Benchmarks] C++ vs Pharo Like this: [ | sum | sum:= 0. 1 to: 1e9 do: [ :i | sum

Re: [Pharo-users] [Stupid Benchmarks] C++ vs Pharo

2016-12-17 Thread Clément Bera
If I am correct, when you do: double x=0; while(x<10) { x = x+1; } C++ compiles the + to double operation. In Pharo, this code: |x| x := 0. 1 to: 10 do:[:each| x := x +1] is using SmallInteger operations. The code you wrote is fully inlined in Cog's JIT (no message s

Re: [Pharo-users] [Stupid Benchmarks] C++ vs Pharo

2016-12-17 Thread Henrik Nergaard
;< std::endl; } Best regards, Henrik From: Pharo-users [mailto:pharo-users-boun...@lists.pharo.org] On Behalf Of Dimitris Chloupis Sent: Saturday, December 17, 2016 1:16 PM To: Any question about pharo is welcome Subject: [Pharo-users] [Stupid Benchmarks] C++ vs Pharo So I was bored and

Re: [Pharo-users] [Stupid Benchmarks] C++ vs Pharo

2016-12-17 Thread Sven Van Caekenberghe
Like this: [ | sum | sum:= 0. 1 to: 1e9 do: [ :i | sum := sum + i ]. sum ] timeToRun. "0:00:00:39.305" cat bench.c #include #include int main() { clock_t begin = clock(); int sum = 0; for (int i = 0; i < 10; i++) sum += i; clock_t end = clock(); double time_spent = (

Re: [Pharo-users] [Stupid Benchmarks] C++ vs Pharo

2016-12-17 Thread Michal Balda
The conditions are unfair: the C++ version uses double, whereas the Pharo version uses Integers. Change the C++ version to use int and then report the results :-). Michal On 17.12.2016 13:16, Dimitris Chloupis wrote: So I was bored and decided to test how fast pharo is compared to C++. so

Re: [Pharo-users] [Stupid Benchmarks] C++ vs Pharo

2016-12-17 Thread Sven Van Caekenberghe
Hmm, this sounds wrong (C++ should be (a lot) faster on such micro benchmarks). You should exclude the executable startup time. In Pharo you should do [ .. ] timeToRun and something similar in C/C++. > On 17 Dec 2016, at 13:41, Dimitris Chloupis wrote: > > in multiplication pharo is around 2 t

Re: [Pharo-users] [Stupid Benchmarks] C++ vs Pharo

2016-12-17 Thread Dimitris Chloupis
in multiplication pharo is around 2 times slower compared to C++ #include int main() { double x=1; for(double i; i<10 ; ++i) { x = 0.1*i; } return 1; } time ./testMul 3.13 real 3.13 user 0.00 sys time ./pharo Ephestos.image eval "|x| x := 1.

[Pharo-users] [Stupid Benchmarks] C++ vs Pharo

2016-12-17 Thread Dimitris Chloupis
So I was bored and decided to test how fast pharo is compared to C++. so I tested addition C++ version: #include int main() { double x=0; while(x<10) { x = x+1; } return 1; } time ./test1 2.84 real 2.84 user 0.00 sys Pharo version: time