random memes }

Example - Mersenne Twister random number generator

Pushed my prior example implementation of the Mersenne Twister into Github. Benchmarked on current hardware (2.3 GHz Intel Core i7 in a Macbook Pro).

$ Release/mersenne-twister
Computed 7309 million primes in 30002 MS - 243.6 m/s

Seems above is about six times faster than an 8-year-old 2200Mhz Athlon. :)

Note there are now faster random number generators, but they tend to be more trouble. This example is very fast, small, and highly portable - in all less trouble.

Also note there are two optimizations (one "extra" value in MT, and map) that remove code from the inner-most loop. (So this should be a touch faster than other implementations.)