gmp-discuss Digest, Vol 203, Issue 3

Marco Bodrato bodrato at mail.dm.unipi.it
Sat Jun 11 20:14:48 CEST 2022


Ciao Seth!

Il 2022-06-05 21:04 Seth Troisi ha scritto:
> Kim Walisch also has a primesieve library which is more of a fair
> comparison than primecount (which doesn't take an optional start)

Yes, but my point was not to compare the speed of a 20-years old (but 
still compiling and smoothly working) pure-C program, with a size on 
disk of 25kbytes; versus a current, partially optimized in assembler 
program, with a size on disk of more than 250kbytes.

I was just trying to answer to the following question:

>> >> This link says there is a segmented version in section 5 of the
>> >> original Atkin/Bernstein  paper. It is unclear if the program above
>> >> has it.

And I think my comparison did it.

You compare:

> $ ./primesieve -t1 1e15-1e9 1e15
> Seconds: 0.373
> Primes: 28954129

With

> $ time ./primes 99999990000000 1000000000000000|wc
> 28954129 28954129 463266064
> real 1m48.190s

But to really be fair, you should ask the same action to both programs:

$ time ./primes 99999990000000 1000000000000000|wc
$ time ./primesieve -t1 99999990000000 1000000000000000 --print|wc


Just for fun, I'd also try how do they work inside valgrind :-)

$ time valgrind primesieve -t1 9999999999999000 10000000000000000 
--print|wc
[...]
==17195==   total heap usage: 174 allocs, 174 frees, 3,804,429 bytes 
allocated
[...]
real	0m11,863s
[...]

$ time valgrind ./primes 9999999999999000 10000000000000000|wc
[...]
==17199==   total heap usage: 1 allocs, 1 frees, 4,096 bytes allocated
[...]
real	4m7,887s
[...]

The older program is slower, but it probably also uses less resources 
:-)

This still is not a fair comparison of the two algorithms: Atkin and 
Erathostene.

Ĝis,
m


More information about the gmp-discuss mailing list