aboutsummaryrefslogtreecommitdiff
path: root/modules/benchmark/cryptohash.c
diff options
context:
space:
mode:
authorbigbear <ns@bigbear.dk>2024-02-08 03:13:01 +0100
committerbigbear <ns@bigbear.dk>2024-02-08 19:52:53 +0100
commit590da61f2e3fbcdb7493485f3e2ea359ccc0ac89 (patch)
tree11942c329bc695e1360f3746217a8b382c4f8637 /modules/benchmark/cryptohash.c
parent1372520972daf599fbaa1f6f0d61a4a8c736db39 (diff)
FIX new benchmarks working for slow & fast machines
Diffstat (limited to 'modules/benchmark/cryptohash.c')
-rw-r--r--modules/benchmark/cryptohash.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/modules/benchmark/cryptohash.c b/modules/benchmark/cryptohash.c
index 32fcfd57..6daef545 100644
--- a/modules/benchmark/cryptohash.c
+++ b/modules/benchmark/cryptohash.c
@@ -1,5 +1,5 @@
/*
- * HardInfo - Displays System Information
+ * HardInfo - System Information and Benchmark
* Copyright (C) 2003-2007 L. A. F. Pereira <l@tia.mat.br>
*
* This program is free software; you can redistribute it and/or modify
@@ -21,13 +21,11 @@
#include "benchmark.h"
/* if anything changes in this block, increment revision */
-#define BENCH_REVISION 1
+#define BENCH_REVISION 2
#define BENCH_DATA_SIZE 65536
+#define CRUNCH_TIME 5
#define BENCH_DATA_MD5 "c25cf5c889f7bead2ff39788eedae37b"
-#define STEPS 5000
-#define CALC_MBs(r) (STEPS*BENCH_DATA_SIZE)/(1024*1024)/r
-/* 5000*65536/(1024*1024) = 312.5 -- old version used 312.0 so results
- * don't exactly compare. */
+#define STEPS 250
inline void md5_step(char *data, glong srclen)
{
@@ -49,15 +47,15 @@ inline void sha1_step(char *data, glong srclen)
SHA1Final(checksum, &ctx);
}
-static gpointer cryptohash_for(unsigned int start, unsigned int end, void *data, gint thread_number)
+static gpointer cryptohash_for(void *in_data, gint thread_number)
{
unsigned int i;
- for (i = start; i <= end; i++) {
+ for (i = 0;i <= STEPS; i++) {
if (i & 1) {
- md5_step(data, BENCH_DATA_SIZE);
+ md5_step(in_data, BENCH_DATA_SIZE);
} else {
- sha1_step(data, BENCH_DATA_SIZE);
+ sha1_step(in_data, BENCH_DATA_SIZE);
}
}
@@ -78,13 +76,14 @@ benchmark_cryptohash(void)
if (!SEQ(d, BENCH_DATA_MD5))
bench_msg("test data has different md5sum: expected %s, actual %s", BENCH_DATA_MD5, d);
- r = benchmark_parallel_for(0, 0, STEPS, cryptohash_for, test_data);
+ r = benchmark_crunch_for(CRUNCH_TIME, 0, cryptohash_for, test_data);
r.revision = BENCH_REVISION;
snprintf(r.extra, 255, "r:%d, d:%s", STEPS, d);
g_free(test_data);
g_free(d);
- r.result = CALC_MBs(r.elapsed_time);
+ r.result /= 10;
+
bench_results[BENCHMARK_CRYPTOHASH] = r;
}