mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 18:36:31 +01:00
Switch to using SIMD-oriented Fast Mersenne Twister for random number generation.
In testing, reduced random number generation time by a factor of 8-10. Drops support for processors older than Pentium 4. Drop Mersenne Twister library; use a C++ SFMT library. --HG-- branch : trunk
This commit is contained in:
@@ -22,36 +22,35 @@
|
||||
|
||||
#include "socket_include.h"
|
||||
#include "utf8.h"
|
||||
//#include "SFMT.h"
|
||||
#include "MersenneTwister.h"
|
||||
#include "sfmt.h"
|
||||
#include <ace/TSS_T.h>
|
||||
|
||||
typedef ACE_TSS<MTRand> MTRandTSS;
|
||||
static MTRandTSS mtRand;
|
||||
typedef ACE_TSS<SFMTRand> SFMTRandTSS;
|
||||
static SFMTRandTSS sfmtRand;
|
||||
|
||||
int32 irand (int32 min, int32 max)
|
||||
{
|
||||
return int32 (mtRand->randInt (max - min)) + min;
|
||||
return int32(sfmtRand->IRandom(min, max));
|
||||
}
|
||||
|
||||
uint32 urand (uint32 min, uint32 max)
|
||||
{
|
||||
return mtRand->randInt (max - min) + min;
|
||||
return sfmtRand->URandom(min, max);
|
||||
}
|
||||
|
||||
int32 rand32 ()
|
||||
{
|
||||
return mtRand->randInt ();
|
||||
return int32(sfmtRand->BRandom());
|
||||
}
|
||||
|
||||
double rand_norm(void)
|
||||
{
|
||||
return mtRand->randExc ();
|
||||
return sfmtRand->Random();
|
||||
}
|
||||
|
||||
double rand_chance (void)
|
||||
{
|
||||
return mtRand->randExc (100.0);
|
||||
return sfmtRand->Random() * 100.0;
|
||||
}
|
||||
|
||||
Tokens StrSplit(const std::string &src, const std::string &sep)
|
||||
|
||||
Reference in New Issue
Block a user