minor fixes in perf test - OG perf measurement version
This commit is contained in:
parent
ef915efdc1
commit
b1d62443f6
11
perf.cpp
11
perf.cpp
@ -1,14 +1,17 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <cassert>
|
||||||
#include "fastrand.h"
|
#include "fastrand.h"
|
||||||
|
|
||||||
#define N 9999999
|
#define N 10000000
|
||||||
#define M 99999999
|
#define M 99999999 // M > N
|
||||||
#define FROM 100
|
#define FROM 100
|
||||||
#define TO 576
|
#define TO 576
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
assert(M > N); // M > N
|
||||||
|
|
||||||
// Init
|
// Init
|
||||||
srand((unsigned int)time(NULL));
|
srand((unsigned int)time(NULL));
|
||||||
rand_state rs = init_rand();
|
rand_state rs = init_rand();
|
||||||
@ -54,14 +57,14 @@ int main() {
|
|||||||
auto t4 = std::chrono::high_resolution_clock::now();
|
auto t4 = std::chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
// lcg + modulo
|
// lcg + modulo
|
||||||
for (int i = 0; i < N; ++i) {
|
for (int i = 0; i < M; ++i) {
|
||||||
sum += FROM + (lcg(&rs) % (TO - FROM));
|
sum += FROM + (lcg(&rs) % (TO - FROM));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto t5 = std::chrono::high_resolution_clock::now();
|
auto t5 = std::chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
// rand_between (also LCG, but no modulus)
|
// 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);
|
sum += rand_between(&rs, FROM, TO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user