- Sieve of Eratosthenes - 11 Updates
- What is visitor pattern? - 2 Updates
Ben Bacarisse <ben.usenet@bsb.me.uk>: Aug 28 12:49AM +0100 >> tests. Shouldn't take too long. > Took 14 minutes to find those 203280221 primes single threaded > on i7-8550U. What do you mean by find? Do you include printing them out because that will depend rather more on the OS. I wanted to try a newer algorithm, so I coded up a rather naive version of Atkin & Bernstein's sieve in C. It needs some tidying and I imagine a bit can be shaved off the time. It can generate a bitmap of the 203280221 primes and then count them in about 40 seconds on an i5-8265U CPU @ 1.60GHz (single threaded). It takes about 55 seconds to write them (in decimal) to a file. The result is over 2GB: $ wc primes 203280221 203280221 2178719347 primes -- Ben. |
Bonita Montero <Bonita.Montero@gmail.com>: Aug 28 06:15AM +0200 I optimized the code somewhat further: #include <iostream> #include <vector> #include <charconv> #include <string_view> #include <algorithm> #include <fstream> #include <cctype> #include <cstring> #include <bit> #include "ndi.h" #if defined(_MSC_VER) #pragma warning(disable: 26495) // uninitialized member
Subscribe to:
Post Comments (Atom)
|
No comments:
Post a Comment