[erlang-questions] Calculate PI in Erlang faster than in Matlab

Zvi <>
Sat Apr 5 20:44:59 CEST 2008


Some more test runs.
My previous runs were performed on my 2-years old laptop:
   Single Intel Core Duo T2500 @ 2GHz (total 2 cores),  2GB RAM

Now I performed some test on my relatively new server machine:   
   Quad Intel Xeon Quad Core @ 2.93GHz (total 16 cores), 8 GB RAM

Erlang (BEAM) emulator version 5.6.1 [smp:16] [async-threads:0]

Eshell V5.6.1  (abort with ^G)
2> c(plists).
{ok,plists}
3> c(pi).
{ok,pi}
4> pi:test().
[{math,{1,3.14159}},
 {list_creation,{108998,3.14159}},
 {lc,{921999,3.14159}},
 {lc_no_pow,{874999,3.14159}},
 {map,{624999,3.14159}},
 {plists_map,{1764999,3.14159}},
 {mapfoldl,{515999,3.14159}},
 {serial_decr,{202999,3.14159}},
 {serial_decr_opt,{327999,3.14159}},
 {serial,{234999,3.14159}},
 {parallel,{14999,3.14159}}]

For some reason, even if each server core is much faster, than single core
in my laptop. The serial benchmarks on the laptop are much better.

But the parallel version takes ~15..16 ms. with a factor of 15.7, i.e.  
234999/14999 = 15.6676.


Zvi

   


Zvi wrote:
> 
> 
> My machine hase dual-core CPU, but I have older version of Matlab, which
> doesn't use all cores, so Matlab version took 125 ms:
> 
>>> tic; N=1000000; Step = 1/N; PI = Step*sum(4./(1+(((1:N)-0.5)*Step).^2));
>>> toc
> Elapsed time is 0.125428 seconds.
> 
> Below is Erlang results:
> 
> 2> c(pi).
> {ok,pi}
> 3> pi:test().
> [{math,{1,3.14159}},
>  {list_creation,{77998,3.14159}},
>  {lc,{671999,3.14159}},
>  {lc_no_pow,{593999,3.14159}},
>  {map,{436999,3.14159}},
>  {mapfoldl,{687999,3.14159}},
>  {serial_decr,{170999,3.14159}},
>  {serial,{171999,3.14159}},
>  {parallel,{93999,3.14159}}]
> 4>
> 
> another run:
> 
> 6> pi:test().
> [{math,{1,3.14159}},
>  {list_creation,{62998,3.14159}},
>  {lc,{671999,3.14159}},
>  {lc_no_pow,{671999,3.14159}},
>  {map,{436999,3.14159}},
>  {mapfoldl,{687999,3.14159}},
>  {serial_decr,{170999,3.14159}},
>  {serial,{171999,3.14159}},
>  {parallel,{77999,3.14159}}]
> 
> 

-- 
View this message in context: http://www.nabble.com/Calculate-PI-in-Erlang-faster-than-in-Matlab-tp16440056p16516522.html
Sent from the Erlang Questions mailing list archive at Nabble.com.




More information about the erlang-questions mailing list