Commit Graph

5 Commits

Author SHA1 Message Date
David Madl
3b63930943 move global Timer to Timer.h
Move ResetUserTime(), PrintUserTime(), GetUserTime() to Timer.h

Do not reset timer in StaticData.
2015-11-17 16:15:13 +00:00
Jeroen Vermeulen
10bd942127 Seed the randomizer once, not every time.
This bit of mira code used to re-seed the randomizer on every call, instead
of just once on startup.  The result of time(NULL) was used as a seed, meaning
that every such call to the randomizer within the same second would return the
same value.
2015-04-24 20:00:07 +07:00
Jeroen Vermeulen
38d790cac0 Add cross-platform randomizer module.
The code uses two mechanisms for generating random numbers: srand()/rand(),
which is not thread-safe, and srandom()/random(), which is POSIX-specific.

Here I add a util/random.cc module that centralizes these calls, and unifies
some common usage patterns.  If the implementation is not good enough, we can
now change it in a single place.

To keep things simple, this uses the portable srand()/rand() but protects them
with a lock to avoid concurrency problems.

The hard part was to keep the regression tests passing: they rely on fixed
sequences of random numbers, so a small code change could break them very
thoroughly.  Util::rand(), for wide types like size_t, calls std::rand() not
once but twice.  This behaviour was generalized into utils::wide_rand() and
friends.
2015-04-23 23:46:04 +07:00
Hieu Hoang
782ac85674 allow mira compilation for Eva 2015-01-08 12:37:34 +00:00
Hieu Hoang
13ec6060b0 move mira code to contrib 2015-01-08 11:49:53 +00:00