From cc3f9da1d2b360f0e5d70b627b1edb2027fa75ea Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Tue, 11 Jun 2024 21:54:01 +0200 Subject: [PATCH] Measure total runtime for self-test and print a score value. The baseline has been measured on Core i5 460M. --- frontend/src/selftest.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/src/selftest.c b/frontend/src/selftest.c index 7c4f506..c173ce0 100644 --- a/frontend/src/selftest.c +++ b/frontend/src/selftest.c @@ -19,6 +19,9 @@ #include #include +/* Performance baseline (measured on Core i5 460M) */ +#define PERF_FACTOR 104319.9 + // ========================================================================== // Self-test routines // ========================================================================== @@ -216,6 +219,7 @@ int selftest_routine(const size_t thread_count, const int debug) const size_t total = ARRAY_SIZE(TEST_NONCE) * (ITERATIONS + (ITERATIONS * ARRAY_SIZE(TEST_STAGE))); size_t count = 0U; + uint64_t total_time = 0U; FPRINTF(stderr, T("Self-test is in progress, please be patient... stage %2u/%2u "), 0U, (unsigned)total); fflush(stderr); @@ -229,10 +233,12 @@ int selftest_routine(const size_t thread_count, const int debug) { FPRINTF(stderr, T("\b\b\b\b\b\b%2u/%2u "), (unsigned)++count, (unsigned)total); fflush(stderr); + const uint64_t clk_start = clock_read(); if (run_testcase(TEST_STAGE[i].text, TEST_NONCE[k], TEST_STAGE[i].check_orig, TEST_STAGE[i].check_encr[j][k], ¶m) != EXIT_SUCCESS) { return EXIT_FAILURE; } + total_time += clock_read() - clk_start; } } } @@ -244,14 +250,16 @@ int selftest_routine(const size_t thread_count, const int debug) { FPRINTF(stderr, T("\b\b\b\b\b\b%2u/%2u "), (unsigned)++count, (unsigned)total); fflush(stderr); + const uint64_t clk_start = clock_read(); if (run_stresstest(TEST_NONCE[j], ¶m) != EXIT_SUCCESS) { return EXIT_FAILURE; } + total_time += clock_read() - clk_start; } } - FPRINTF(stderr, T("\b\b\b\b\b\b%2u/%2u\n\nCompleted successfully.\n\n"), (unsigned)total, (unsigned)total); + FPRINTF(stderr, T("\b\b\b\b\b\b%2u/%2u\n\nCompleted successfully. (Score: %.0f)\n\n"), (unsigned)total, (unsigned)total, (double)clock_freq() / (double)total_time * PERF_FACTOR); fflush(stderr); return EXIT_SUCCESS;