diff --git a/perf.cpp b/perf.cpp index 2d6317f..eedba51 100644 --- a/perf.cpp +++ b/perf.cpp @@ -1,14 +1,17 @@ #include #include #include +#include #include "fastrand.h" -#define N 9999999 -#define M 99999999 +#define N 10000000 +#define M 99999999 // M > N #define FROM 100 #define TO 576 int main() { + assert(M > N); // M > N + // Init srand((unsigned int)time(NULL)); rand_state rs = init_rand(); @@ -54,14 +57,14 @@ int main() { auto t4 = std::chrono::high_resolution_clock::now(); // lcg + modulo - for (int i = 0; i < N; ++i) { + for (int i = 0; i < M; ++i) { sum += FROM + (lcg(&rs) % (TO - FROM)); } auto t5 = std::chrono::high_resolution_clock::now(); // rand_between (also LCG, but no modulus) - for (int i = 0; i < N; ++i) { + for (int i = 0; i < M; ++i) { sum += rand_between(&rs, FROM, TO); }