From 36afe7f533c63d15375e5b862c9760f801498e3d Mon Sep 17 00:00:00 2001 From: dzaima Date: Fri, 30 Jul 2021 02:19:15 +0300 Subject: [PATCH] integrate mode for consistent timing use with make t=perftest f='-O3 -DPERF_TEST' c --- src/main.c | 19 +++++++++++++------ src/utils/hash.c | 6 +++++- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/main.c b/src/main.c index 5cd2710e..ad0aade1 100644 --- a/src/main.c +++ b/src/main.c @@ -55,6 +55,9 @@ int main(int argc, char* argv[]) { #endif bool startREPL = argc==1; bool silentREPL = false; + #ifdef PERF_TEST + silentREPL = true; + #endif if (!startREPL) { i32 i = 1; while (i!=argc) { @@ -171,13 +174,17 @@ int main(int argc, char* argv[]) { #endif ptr_dec(block); - #if FORMATTER - B resFmt = bqn_fmt(res); - printRaw(resFmt); dec(resFmt); - putchar('\n'); + #ifndef PERF_TEST + #if FORMATTER + B resFmt = bqn_fmt(res); + printRaw(resFmt); dec(resFmt); + putchar('\n'); + #else + print(res); putchar('\n'); fflush(stdout); + dec(res); + #endif #else - print(res); putchar('\n'); fflush(stdout); - dec(res); + dec(res); #endif #ifdef HEAP_VERIFY diff --git a/src/utils/hash.c b/src/utils/hash.c index aed205de..6ec090b5 100644 --- a/src/utils/hash.c +++ b/src/utils/hash.c @@ -7,6 +7,10 @@ void hash_init() { u64 bad1=0xa0761d6478bd642full; // values wyhash64 is afraid of u64 bad2=0xe7037ed1a0b428dbull; again: - make_secret(nsTime(), wy_secret); + #ifdef PERF_TEST + make_secret(0, wy_secret); + #else + make_secret(nsTime(), wy_secret); + #endif for (u64 i = 0; i < 4; i++) if(wy_secret[i]==bad1 || wy_secret[i]==bad2) goto again; }