Hello all,

Thank you all for helping out here. However, I have to withdraw this report
in embarrassment. I've actually found a bug in my code that was causing the
library function to sum up incorrectly. Note to self: Always assume you're
wrong.

In any case, once the bug was corrected, the performance of the Prime class
significantly improved. It is still more than twice as slow as the
Eratosthenes function, but I'm guessing this is something that has been
corrected in 1.9.

Here are the post-bug benchmarks for Prime class and hand-rolled
Eratosthenes:

                                               user          system
total        real
library up to 100,000                  0.687000   0.015000   0.702000 (
0.703000)
library up to 1,000,000               8.094000   0.000000   8.094000 (
8.110000)

eratosthenes up to 100,000        0.360000   0.000000   0.360000 (
0.359000)
eratosthenes up to 1,000,000     3.844000   0.032000   3.876000 (  3.875000=
)

Run # 2:
                                               user         system
total        real
library up to 100,000                 0.703000   0.000000   0.703000 (
0.703000)
library up to 1,000,000              8.125000   0.047000   8.172000 (
8.203000)
library full run: 2,000,000           8.047000   0.046000   8.093000 (
8.125000)

eratosthenes up to 100,000         0.360000   0.000000   0.360000 (
0.359000)
eratosthenes up to 1,000,000      3.906000   0.000000   3.906000 (
3.906000)
eratosthenes full run: 2,000,000   3.844000   0.032000   3.876000 (
3.875000)

Again, thanks all for your help.

Srdjan

On Thu, Jul 9, 2009 at 7:41 AM, Shot (Piotr Szotkowski) <shot / hot.pl> wrote=
:

> Gregory Brown:
>
> > Just for specific details:
>
> > sandal:~ $ ruby19 -v
> > ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-darwin9.4.0]
> > sandal:~ $ uname -a
> > Darwin anatta.local 9.6.0 Darwin Kernel Version 9.6.0: Mon Nov 24
> 17:37:00 PST 2008; root:xnu-1228.9.59~1/RELEASE_I386 i386
> > sandal:~ $ time ruby19 -rprime -e "Prime.take_while { |e| e < 2_000_000
> }.inject { |s,r| s + r }"
>
> > real  0m2.956s
> > user  0m2.883s
> > sys   0m0.028s
>
> FWIW, it does indeed looks like a Windows binary issue:
>
> shot@devielle:~$ grep 'model name' /proc/cpuinfo
> model name  : Intel(R) Core(TM)2 Duo CPU     U9400  @ 1.40GHz
> model name  : Intel(R) Core(TM)2 Duo CPU     U9400  @ 1.40GHz
> shot@devielle:~$ uname -a
> Linux devielle 2.6.30-020630-generic #020630 SMP Wed Jun 10 09:04:38 UTC
> 2009 x86_64 GNU/Linux
> shot@devielle:~$ time ruby -vrprime -e 'Prime.take_while { |e| e <
> 2_000_000 }.inject(:+)'
> ruby 1.9.1p129 (2009-05-12 revision 23412) [x86_64-linux]
>
> real  0m3.107s
> user  0m3.092s
> sys 0m0.012s
>
> =97 Shot
> --
> I consider chromatic to be Larry Wall=92s Thomas
> Huxley.    [Jarkko Hietaniemi, hates-software]
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
>
> iEYEARECAAYFAkpV12QACgkQi/mCfdEo8UreFgCfQglZ6vrk2wQ2JR7sLlppxh7E
> g/MAoKTqNXpvIlmTmt1droAkKezp651T
> =3DfaN6
> -----END PGP SIGNATURE-----
>
>