From 1a008865df39382cf9bc6f5afa5a0eae34686513 Mon Sep 17 00:00:00 2001 From: Zihao Yu Date: Thu, 28 Jan 2021 15:59:55 +0800 Subject: [PATCH] microbench: explicitly use uint32_t for score and uint64_t for usec --- benchmarks/microbench/src/bench.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/benchmarks/microbench/src/bench.c b/benchmarks/microbench/src/bench.c index a8330bf..52cf6b2 100644 --- a/benchmarks/microbench/src/bench.c +++ b/benchmarks/microbench/src/bench.c @@ -54,7 +54,7 @@ static void run_once(Benchmark *b, Result *res) { res->pass = current->validate(); } -static unsigned long score(Benchmark *b, unsigned long usec) { +static uint32_t score(Benchmark *b, uint64_t usec) { if (usec == 0) return 0; return (uint64_t)(REF_SCORE) * setting->ref / usec; } @@ -81,7 +81,7 @@ int main(const char *args) { printf("======= Running MicroBench [input *%s*] =======\n", setting_name); - unsigned long bench_score = 0; + uint32_t bench_score = 0; int pass = 1; uint64_t t0 = uptime(); uint64_t score_time = 0; @@ -95,7 +95,7 @@ int main(const char *args) { if (msg != NULL) { printf("Ignored %s\n", msg); } else { - unsigned long usec = ULONG_MAX; + uint64_t usec = ULLONG_MAX; int succ = 1; for (int i = 0; i < REPEAT; i ++) { Result res; @@ -111,7 +111,7 @@ int main(const char *args) { pass &= succ; - unsigned long cur = succ ? score(bench, usec) : 0; + uint32_t cur = succ ? score(bench, usec) : 0; printf("\n"); if (setting_id != 0) { @@ -129,7 +129,7 @@ int main(const char *args) { printf("==================================================\n"); printf("MicroBench %s", pass ? "PASS" : "FAIL"); if (setting_id >= 2) { - printf(" %d Marks\n", (unsigned int)bench_score); + printf(" %d Marks\n", bench_score); printf(" vs. %d Marks (%s)\n", REF_SCORE, REF_CPU); } else { printf("\n");