/ 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
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
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
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
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
-
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
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
;< 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
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 = (
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
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
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.
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
13 matches
Mail list logo