development:testing_and_prng
Differences
This shows you the differences between two versions of the page.
| development:testing_and_prng [2025/10/30] – created hayati | development:testing_and_prng [Unknown date] (current) – external edit (Unknown date) 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ~~NOTRANS~~ | ||
| + | {{indexmenu_n> | ||
| + | |||
| + | ====== Testing, Reproducibility and Random Numbers ====== | ||
| + | |||
| + | ===== General ===== | ||
| + | |||
| + | Software needs testing .. and many tests can be automized with unittests - or integration tests.\\ | ||
| + | The program/ | ||
| + | |||
| + | ===== Crash early! ===== | ||
| + | |||
| + | Especially when the program or it's results must be reliable, **crashing early** might be advised!\\ | ||
| + | In this case, additional checks should be enforced and executed. Note, that the C '' | ||
| + | |||
| + | Besides executing explicitly programmed checks, there are also other possibilities: | ||
| + | * setup signal handler, e.g. segmentation fault (SIGSEGV) | ||
| + | * setup floating point traps, see [[development: | ||
| + | * compile with automatic checks | ||
| + | * see https:// | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * see https:// | ||
| + | * sanitizers like the prominent AddressSanitizer ' | ||
| + | * stack-protector | ||
| + | * and others | ||
| + | |||
| + | A welcomed side effect of crashing early:\\ | ||
| + | the stack trace and the visible variable contents might reveal the initial cause of the problem\\ | ||
| + | - at least with a much higher probability than after having continued and covered the problem. | ||
| + | |||
| + | |||
| + | ===== Core-Dumps ===== | ||
| + | |||
| + | A core-dump / minidump mechanism might be of interest.\\ | ||
| + | For tracking very rare or specific errors, this mechanism might also get delivered to customers. | ||
| + | |||
| + | |||
| + | ===== Pseudo Random Number Generators (PRNG) ===== | ||
| + | |||
| + | For tests, a huge amount of '// | ||
| + | There' | ||
| + | Test with defined // | ||
| + | |||
| + | ==== Algorithms / Libraries ==== | ||
| + | |||
| + | === Properties === | ||
| + | |||
| + | * size of the //seed// or //state// | ||
| + | * small size is of interest to use one PRNG per thread | ||
| + | * quick initialization from seed | ||
| + | * speed, for producing next number | ||
| + | * period size - until the sequence repeats | ||
| + | |||
| + | === Linear congruential generator (LCG) === | ||
| + | |||
| + | //LCG// is perhaps the simplest (and fastest) algorithm with a small seed; see https:// | ||
| + | |||
| + | //Fast skipping// might be of interest; see https:// | ||
| + | |||
| + | === Xorshift === | ||
| + | |||
| + | Also a very fast PRNG. Here some links | ||
| + | |||
| + | * https:// | ||
| + | * [[https:// | ||
| + | * http:// | ||
| + | * https:// | ||
| + | * http:// | ||
| + | |||
| + | === Mersenne Twister === | ||
| + | |||
| + | This PRNG got hyped in the C++ community for it's ridiculously huge period size - but has a big seed size and it's initialization isn't the fastest. IMHO, in most applications, | ||
| + | |||
| + | Anyway, here a link to a SIMD-oriented implementation: | ||
| + | |||
| + | === Other Links === | ||
| + | |||
| + | * PCG - comparison of Mersenne Twister, Arc4, .. | ||
| + | * https:// | ||
| + | * 64 bit version of Mersenne Twister | ||
| + | * http:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * CppCon 2016: Cheinan Marks “I Just Wanted a Random Integer! | ||
| + | * https:// | ||
| + | * CppCon 2016: Walter E. Brown "What C++ Programmers Need to Know about Header < | ||
| + | * https:// | ||
| + | * CppCon 2022: Roth Michaels "Fast, High-Quality Pseudo-Random Numbers for Non-Cryptographers" | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * Vectorized (SIMD) generation | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * Github | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
