c - Faster than rand()? -
i'm working on algorithm needs generate millions of numbers fast possible. found out rand() function of algorithm takes 75% of process time.
so i'm looking faster. , don't need big range @ all. (i need integer numbers below 1000)
do know utilize ?
thanks !
edit :
i utilize numbers shuffling groups of less 1000 entities.
i found out more "fast rand". , there sse version version faster , generates 4 numbers @ time.
https://software.intel.com/en-us/articles/fast-random-number-generator-on-the-intel-pentiumr-4-processor/
static unsigned int g_seed; //used seed generator. inline void fast_srand( int seed ) { g_seed = seed; } //fastrand routine returns 1 integer, similar output value range c lib. inline int fastrand() { g_seed = (214013*g_seed+2531011); homecoming (g_seed>>16)&0x7fff; }
c random
No comments:
Post a Comment