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 <[email protected]> wrote:
> 
> in multiplication pharo is around 2 times slower compared to C++
> 
> #include <stdio.h>
> 
> int main()
> {
>   double x=1;
>   for(double i; i<1000000000 ; ++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. 1 to: 1000000000 do:[:each| x 
> := 0.1 * each]"
> 1
>         4.97 real         4.48 user         0.09 sys
> 
> On Sat, Dec 17, 2016 at 2:16 PM Dimitris Chloupis <[email protected]> 
> wrote:
> So I was bored and decided to test how fast pharo is compared to C++. 
> 
> so I tested addition 
> 
> C++ version:
> 
> #include <stdio.h>
> 
> int main()
> {
>   double x=0;
>   while(x<1000000000)
>     {
>     x = x+1;
>     }
> 
>   return 1;
>   }
> 
>  time ./test1
>         2.84 real         2.84 user         0.00 sys
> 
> Pharo version:
> 
> time ./pharo Ephestos.image eval "|x| x := 0. 1 to: 1000000000 do:[:each| x 
> := x +1]"
> 1
>         2.09 real         1.94 user         0.08 sys
> 
> Pharo is +50% faster than C++ ... o_O ... that's suprising, I assume here 
> Pharo VM probably does some kind of optimisation. 
> 


Reply via email to