On Sunday 15 July 2007 11:19:29 Hugh Perkins wrote: > Not only does mono come close to the Microsoft .Net time, both mono and > Microsoft .Net are faster than g++ ;-) and whack Haskell.
This should tell you that your C++ is not very good. This is several times faster, for example: #include <iostream> #include <ctime> #include <vector> using namespace std; int CalculateNumberOfPrimes(int maxprime) { vector<bool> NotPrime(maxprime+1); int NumberOfPrimes = 0; for (int i = 2; i <= maxprime; i++ ) if (!NotPrime[i]) { ++NumberOfPrimes; for (int j = 2*i; j <= maxprime; j += i) if (!NotPrime[j]) NotPrime[j] = true; } return NumberOfPrimes; } For some reason you were using C-style allocation rather than the C++ STL to implement a bit vector. The STL implementation is optimized. -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. The OCaml Journal http://www.ffconsultancy.com/products/ocaml_journal/?e _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe