Random number generation

From reSIProcate
Revision as of 15:41, 7 February 2011 by Kwhite (talk | contribs) (new page, early draft)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This section describes some options and performance measurements of the rutil/Random class.

The Random class has compile time options to control how it generates random numbers. It is control via pre-process symbols, defined either by changing Random.hxx or in the build environment.


The choices are:

[WIN32-default] The Random class uses rand().

RESIP_RANDOM_WIN32_RTL The Random class uses Window's RtlGenRandom (aka SystemFunction036) on XP and higher system, and fallsback to rand() on older Windows platforms.

[POSIX-default] The Random class uses libc's random().

RESIP_RANDOM_THREAD_MUTEX The Random class itself keeps a Mutex, and will lock the mutex prior to calling random_r().

RESIP_RANDOM_THREAD_LOCAL The Random class allocate state for each thread and tracks that using ThreadLocalStorage.


Linux Performance results