minor fixes in perf test - OG perf measurement version

This commit is contained in:
Richard Thier 2025-04-01 20:06:11 +02:00
parent ef915efdc1
commit b1d62443f6

View File

@ -1,14 +1,17 @@
#include <cstdio>
#include <cstdlib>
#include <chrono>
#include <cassert>
#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);
}