shootout - nsieve-bits benchmark

Ulf Wiger (AL/EAB) ulf.wiger@REDACTED
Fri Apr 21 19:00:45 CEST 2006

I noticed that Erlang HiPE times out on the nsieve-bits benchmark.
That's not very flattering, since the upper limit is 3600 seconds. (:


I did some tests with the posted Erlang version, and it does take a
_very_ long time for large input (it also seems to return incorrect
values as N increases. I don't know why.)

I attach a version that uses an ordered_set ets table for a bit array.
It at least puts Erlang at the level of Tcl/JavaScript, and well before
Ruby (assuming that the Pentium 4 box performs at least as well as my
SunBLADE). It also matches the output of the other implementations (it
also seems to agree with Doug Bagley's old sieve program, found at

I haven't submitted it. Does anyone have a better implementation?

1> c(sv,[native]).           
2> timer:tc(sv,main,[["9"]]).
Primes up to  5120000  356244
Primes up to  2560000  187134
Primes up to  1280000   98610

Ulf W
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sv.erl
Type: application/octet-stream
Size: 3409 bytes
Desc: sv.erl
URL: <>

More information about the erlang-questions mailing list