Measure total runtime for self-test and print a score value. The baseline has been measured on Core i5 460M.

This commit is contained in:
LoRd_MuldeR 2024-06-11 21:54:01 +02:00
parent 37c4beca01
commit cc3f9da1d2
Signed by: mulder
GPG Key ID: 2B5913365F57E03F

View File

@ -19,6 +19,9 @@
#include <ctype.h>
#include <assert.h>
/* 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], &param) != 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], &param) != 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;