aboutsummaryrefslogtreecommitdiff
path: root/modules/benchmark/cryptohash.c
diff options
context:
space:
mode:
authorBurt P <pburt0@gmail.com>2019-08-10 23:11:21 -0500
committerLeandro A. F. Pereira <leandro@hardinfo.org>2019-08-14 20:02:42 -0700
commitd17909c82b03ad0427a285c66766421751546c42 (patch)
tree485588a0822984d437fcd22ed9f23f441760ca72 /modules/benchmark/cryptohash.c
parent30508a10bf269e5ca06226fb50c86f5249cc746a (diff)
Benchmark: fixes, user_note, verifiable test data
* fix zlib display order * fix cryptohash MiB/s calculation * revision and params for other benchmarks * allow attaching user note to bench result with -u * don't inlcude the new result value bits if they are empty/invalid in bench_value_to_str(). bench_value_from_str() doesn't need to be modified. * bench_results: clean old result cpu name for x86 * use problem_marker() from dmi_memory to mark old version bench results * benchmark: verifiable test data size and content - The test data benchmark.data is stored in a file that could be edited to change the size or content. /* to guarantee size */ gchar *get_test_data(gsize min_size); /* to checksum content */ char *md5_digest_str(const char *data, unsigned int len); Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'modules/benchmark/cryptohash.c')
-rw-r--r--modules/benchmark/cryptohash.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/modules/benchmark/cryptohash.c b/modules/benchmark/cryptohash.c
index 6150f3ef..cf6f998e 100644
--- a/modules/benchmark/cryptohash.c
+++ b/modules/benchmark/cryptohash.c
@@ -20,6 +20,15 @@
#include "sha1.h"
#include "benchmark.h"
+/* if anything changes in this block, increment revision */
+#define BENCH_REVISION 1
+#define BENCH_DATA_SIZE 65536
+#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. */
+
void inline md5_step(char *data, glong srclen)
{
struct MD5Context ctx;
@@ -46,9 +55,9 @@ static gpointer cryptohash_for(unsigned int start, unsigned int end, void *data,
for (i = start; i <= end; i++) {
if (i & 1) {
- md5_step(data, 65536);
+ md5_step(data, BENCH_DATA_SIZE);
} else {
- sha1_step(data, 65536);
+ sha1_step(data, BENCH_DATA_SIZE);
}
}
@@ -59,22 +68,23 @@ void
benchmark_cryptohash(void)
{
bench_value r = EMPTY_BENCH_VALUE;
- gchar *tmpsrc, *bdata_path;
-
- bdata_path = g_build_filename(params.path_data, "benchmark.data", NULL);
- if (!g_file_get_contents(bdata_path, &tmpsrc, NULL, NULL)) {
- g_free(bdata_path);
- return;
- }
+ gchar *test_data = get_test_data(BENCH_DATA_SIZE);
+ if (!test_data) return;
shell_view_set_enabled(FALSE);
shell_status_update("Running CryptoHash benchmark...");
- r = benchmark_parallel_for(0, 0, 5000, cryptohash_for, tmpsrc);
+ gchar *d = md5_digest_str(test_data, BENCH_DATA_SIZE);
+ 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.revision = BENCH_REVISION;
+ snprintf(r.extra, 255, "r:%d, d:%s", STEPS, d);
- g_free(bdata_path);
- g_free(tmpsrc);
+ g_free(test_data);
+ g_free(d);
- r.result = 312.0 / r.elapsed_time; //TODO: explain in code comments
+ r.result = CALC_MBs(r.elapsed_time);
bench_results[BENCHMARK_CRYPTOHASH] = r;
}