Random number generators discussion

Random number generators | www.agner.org

 
thread MT speed compared to rand() - Koshmaar - 2008-02-09
last reply MT speed compared to rand() - Agner - 2008-02-10
 
MT speed compared to rand()
Author:  Date: 2008-02-09 16:00
Hi, I have a quick question... compared to std rand() function, Mersenne Twister implementation in your library "provides random number generators of a much better quality: Better randomness, higher resolution, and longer cycle lengths". Does it also surpass it in terms of speed? I ask, since I might need to generate tens of thousands random numbers every game frame (don't ask what for... ) and every cycle counts... Have you done any benchmarks? is it faster or slower than rand()? what about C++ and assembler versions?

Thanks in advance

   
MT speed compared to rand()
Author: Agner Date: 2008-02-10 07:45
The implementation of Rand() differs for different compiler libraries. Some are eqtremely fast but not very random. Mersenne twister is pretty fast, maybe 20 nanoseconds. I'm sure that's fast enough for most applications. The assembly version in asmlib is faster than the C++ version.