From 00719182d5f3d49e89b2f985a250b626ce9e5a06 Mon Sep 17 00:00:00 2001 From: David Garske Date: Fri, 23 Jun 2023 14:17:22 -0700 Subject: [PATCH] Fix for benchmark always using 4KB of memory for `gStats`, even when not required. Added new `WC_BENCH_TRACK_STATS` to enable feature is needed. Code cleanups for line length and headers. --- wolfcrypt/benchmark/benchmark.c | 430 ++++++++++++++++++-------------- 1 file changed, 244 insertions(+), 186 deletions(-) diff --git a/wolfcrypt/benchmark/benchmark.c b/wolfcrypt/benchmark/benchmark.c index 6609a2e20..420827db1 100644 --- a/wolfcrypt/benchmark/benchmark.c +++ b/wolfcrypt/benchmark/benchmark.c @@ -22,48 +22,178 @@ /* wolfCrypt benchmark */ +/* Some common, optional build settings: + * these can also be set in wolfssl/options.h or user_settings.h + * ------------------------------------------------------------- + * make the binary always use CSV format: + * WOLFSSL_BENCHMARK_FIXED_CSV + * + * choose to use the same units, regardless of scale. pick 1: + * WOLFSSL_BENCHMARK_FIXED_UNITS_GB + * WOLFSSL_BENCHMARK_FIXED_UNITS_MB + * WOLFSSL_BENCHMARK_FIXED_UNITS_KB + * WOLFSSL_BENCHMARK_FIXED_UNITS_B + * + * when the output should be in machine-parseable format: + * GENERATE_MACHINE_PARSEABLE_REPORT + * + * Enable tracking of the stats into a static buffer (MAX_BENCH_STATS): + * WC_BENCH_TRACK_STATS + */ + #ifdef HAVE_CONFIG_H #include #endif -/* Some common, optional user settings */ -/* these can also be set in wolfssl/options.h or user_settings.h */ -/* ------------------------------------------------------------- */ -/* make the binary always use CSV format: */ -/* #define WOLFSSL_BENCHMARK_FIXED_CSV */ -/* */ -/* choose to use the same units, regardless of scale. pick 1: */ -/* #define WOLFSSL_BENCHMARK_FIXED_UNITS_GB */ -/* #define WOLFSSL_BENCHMARK_FIXED_UNITS_MB */ -/* #define WOLFSSL_BENCHMARK_FIXED_UNITS_KB */ -/* #define WOLFSSL_BENCHMARK_FIXED_UNITS_B */ -/* */ -/* when the output should be in machine-parseable format: */ -/* #define GENERATE_MACHINE_PARSEABLE_REPORT */ -/* */ - -/* define the max length for each string of metric reported */ -#define __BENCHMARK_MAXIMUM_LINE_LENGTH 150 - -/* some internal helpers to get values of settings */ -/* this first one gets the text name of the #define parameter */ -#define __BENCHMARK_VALUE_TO_STRING(x) #x - -/* this next one gets the text value of the assigned value of #define param */ -#define __BENCHMARK_VALUE(x) __BENCHMARK_VALUE_TO_STRING(x) - -#define WOLFSSL_FIXED_UNITS_PER_SEC "MB/s" /* may be re-set by fixed units */ - #ifndef WOLFSSL_USER_SETTINGS #include #endif #include /* also picks up user_settings.h */ + +/* Macro to disable benchmark */ +#ifndef NO_CRYPT_BENCHMARK + #include -#include #include -#include #include +#include +#include +#include +#include +#include + +#ifdef HAVE_CHACHA + #include +#endif +#ifdef HAVE_POLY1305 + #include +#endif +#if defined(HAVE_CHACHA) && defined(HAVE_POLY1305) + #include +#endif +#ifndef NO_AES + #include +#endif +#ifdef HAVE_CAMELLIA + #include +#endif +#ifndef NO_MD5 + #include +#endif +#ifndef NO_SHA + #include +#endif +#ifndef NO_SHA256 + #include +#endif +#if defined(WOLFSSL_SHA512) || defined(WOLFSSL_SHA384) + #include +#endif +#ifdef WOLFSSL_SHA3 + #include +#endif +#ifndef NO_RSA + #include +#endif +#ifdef WOLFSSL_RIPEMD + #include +#endif +#ifdef WOLFSSL_CMAC + #include +#endif +#ifndef NO_DH + #include +#endif +#ifndef NO_DES3 + #include +#endif +#ifndef NO_RC4 + #include +#endif +#ifndef NO_HMAC + #include +#endif +#ifdef WOLFSSL_SIPHASH + #include +#endif +#ifndef NO_PWDBASED + #include +#endif +#ifdef HAVE_ECC + #include +#endif +#ifdef HAVE_CURVE25519 + #include +#endif +#ifdef HAVE_ED25519 + #include +#endif +#ifdef HAVE_CURVE448 + #include +#endif +#ifdef HAVE_ED448 + #include +#endif +#ifdef WOLFSSL_HAVE_KYBER + #include +#ifdef WOLFSSL_WC_KYBER + #include +#endif +#if defined(HAVE_LIBOQS) || defined(HAVE_PQM4) + #include +#endif +#endif +#ifdef WOLFCRYPT_HAVE_ECCSI + #include +#endif +#ifdef WOLFCRYPT_HAVE_SAKKE + #include +#endif + +#if defined(HAVE_PQC) + #if defined(HAVE_FALCON) + #include + #endif + #if defined(HAVE_DILITHIUM) + #include + #endif + #if defined(HAVE_SPHINCS) + #include + #endif +#endif + +#ifdef WOLF_CRYPTO_CB + #include + #ifdef HAVE_INTEL_QA_SYNC + #include + #endif + #ifdef HAVE_CAVIUM_OCTEON_SYNC + #include + #endif + #ifdef HAVE_RENESAS_SYNC + #include + #endif +#endif + +#ifdef WOLFSSL_ASYNC_CRYPT + #include +#endif + +#ifdef USE_FLAT_BENCHMARK_H + #include "benchmark.h" +#else + #include "wolfcrypt/benchmark/benchmark.h" +#endif + + +/* define the max length for each string of metric reported */ +#ifndef WC_BENCH_MAX_LINE_LEN +#define WC_BENCH_MAX_LINE_LEN 150 +#endif + +/* default units per second. See WOLFSSL_BENCHMARK_FIXED_UNITS_* to change */ +#define WOLFSSL_FIXED_UNITS_PER_SEC "MB/s" /* may be re-set by fixed units */ #ifdef WOLFSSL_NO_FLOAT_FMT #define FLT_FMT "%0ld,%09lu" @@ -92,7 +222,7 @@ #define FLT_FMT_ARGS(x) x #define FLT_FMT_PREC_ARGS(p, x) p, x #define FLT_FMT_PREC2_ARGS(w, p, x) w, p, x -#endif +#endif /* WOLFSSL_NO_FLOAT_FMT */ #ifdef WOLFSSL_ESPIDF #if defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C6) @@ -111,11 +241,12 @@ #error "CONFIG_IDF_TARGET not implemented" #endif #include -#endif +#endif /* WOLFSSL_ESPIDF */ #ifdef HAVE_PTHREAD #include #endif + #if defined(HAVE_PTHREAD) || \ (!defined(NO_CRYPT_BENCHMARK) && !defined(NO_STDIO_FILESYSTEM) && \ !defined(NO_ERROR_STRINGS) && !defined(NO_MAIN_DRIVER) && \ @@ -127,28 +258,17 @@ #endif #if defined(WOLFSSL_ZEPHYR) || defined(NO_STDIO_FILESYSTEM) || !defined(XFFLUSH) -/* fflush in Zephyr doesn't work on stdout and stderr. Use - * CONFIG_LOG_MODE_IMMEDIATE compilation option instead. */ -#undef XFFLUSH -#define XFFLUSH(...) do {} while (0) + /* fflush in Zephyr doesn't work on stdout and stderr. Use + * CONFIG_LOG_MODE_IMMEDIATE compilation option instead. */ + #undef XFFLUSH + #define XFFLUSH(...) do {} while (0) #endif -/* Macro to disable benchmark */ -#ifndef NO_CRYPT_BENCHMARK - -#include - /* only for stack size check */ -#if defined(WOLFSSL_ASYNC_CRYPT) - #ifndef WC_NO_ASYNC_THREADING - #define WC_ENABLE_BENCH_THREADING - #endif -#endif +#include -#ifdef USE_FLAT_BENCHMARK_H - #include "benchmark.h" -#else - #include "wolfcrypt/benchmark/benchmark.h" +#if defined(WOLFSSL_ASYNC_CRYPT) && !defined(WC_NO_ASYNC_THREADING) + #define WC_ENABLE_BENCH_THREADING #endif #ifdef GENERATE_MACHINE_PARSEABLE_REPORT @@ -189,7 +309,7 @@ static int printfk(const char *fmt, ...) { int ret; - char line[__BENCHMARK_MAXIMUM_LINE_LENGTH]; + char line[WC_BENCH_MAX_LINE_LEN]; va_list ap; va_start(ap, fmt); @@ -258,98 +378,6 @@ #endif #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef NO_HMAC - #include -#endif -#ifdef WOLFSSL_SIPHASH - #include -#endif -#ifndef NO_PWDBASED - #include -#endif -#ifdef HAVE_ECC - #include -#endif -#ifdef HAVE_CURVE25519 - #include -#endif -#ifdef HAVE_ED25519 - #include -#endif -#ifdef HAVE_CURVE448 - #include -#endif -#ifdef HAVE_ED448 - #include -#endif -#ifdef WOLFSSL_HAVE_KYBER - #include -#ifdef WOLFSSL_WC_KYBER - #include -#endif -#if defined(HAVE_LIBOQS) || defined(HAVE_PQM4) - #include -#endif -#endif -#ifdef WOLFCRYPT_HAVE_ECCSI - #include -#endif -#ifdef WOLFCRYPT_HAVE_SAKKE - #include -#endif - -#if defined(HAVE_PQC) - #if defined(HAVE_FALCON) - #include - #endif - #if defined(HAVE_DILITHIUM) - #include - #endif - #if defined(HAVE_SPHINCS) - #include - #endif -#endif - -#include -#include -#include -#include - -#ifdef WOLF_CRYPTO_CB - #include - #ifdef HAVE_INTEL_QA_SYNC - #include - #endif - #ifdef HAVE_CAVIUM_OCTEON_SYNC - #include - #endif - #ifdef HAVE_RENESAS_SYNC - #include - #endif -#endif - -#ifdef WOLFSSL_ASYNC_CRYPT - #include -#endif - #ifdef HAVE_FIPS #include @@ -861,7 +889,8 @@ static int lng_index = 0; #ifndef MAIN_NO_ARGS static const char* bench_Usage_msg1[][21] = { /* 0 English */ - { "-? Help, print this usage\n 0: English, 1: Japanese\n", + { "-? Help, print this usage\n" + " 0: English, 1: Japanese\n", "-csv Print terminal output in csv format\n", "-base10 Display bytes as power of 10 (eg 1 kB = 1000 Bytes)\n", "-no_aad No additional authentication data passed.\n", @@ -881,9 +910,11 @@ static const char* bench_Usage_msg1[][21] = { "-p521 Measure ECC using P-521 curve.\n", "-ecc-all Bench all enabled ECC curves.\n", "- Algorithm to benchmark. Available algorithms include:\n", - "-lng Display benchmark result by specified language.\n 0: English, 1: Japanese\n", + "-lng Display benchmark result by specified language.\n" + " 0: English, 1: Japanese\n", " Size of block in bytes\n", - ("-blocks Number of blocks. Can be used together with the 'Size of block'\n" + ("-blocks Number of blocks. Can be used together with the " + "'Size of block'\n" " option, but must be used after that one.\n" ), "-threads Number of threads to run\n", @@ -891,7 +922,8 @@ static const char* bench_Usage_msg1[][21] = { }, #ifndef NO_MULTIBYTE_PRINT /* 1 Japanese */ - { "-? ヘルプ, 使い方を表示します。\n 0: 英語、 1: 日本語\n", + { "-? ヘルプ, 使い方を表示します。\n" + " 0: 英語、 1: 日本語\n", "-csv csv 形式で端末に出力します。\n", "-base10 バイトを10のべき乗で表示します。(例 1 kB = 1000 Bytes)\n", "-no_aad 追加の認証データを使用しません.\n", @@ -906,8 +938,10 @@ static const char* bench_Usage_msg1[][21] = { "-p384 Measure ECC using P-384 curve.\n", "-p521 Measure ECC using P-521 curve.\n", "-ecc-all Bench all enabled ECC curves.\n", - "- アルゴリズムのベンチマークを実施します。\n 利用可能なアルゴリズムは下記を含みます:\n", - "-lng 指定された言語でベンチマーク結果を表示します。\n 0: 英語、 1: 日本語\n", + "- アルゴリズムのベンチマークを実施します。\n" + " 利用可能なアルゴリズムは下記を含みます:\n", + "-lng 指定された言語でベンチマーク結果を表示します。\n" + " 0: 英語、 1: 日本語\n", " ブロックサイズをバイト単位で指定します。\n", "-blocks TBD.\n", "-threads 実行するスレッド数\n", @@ -1242,7 +1276,8 @@ static const char* bench_result_words2[][5] = { /* if algo doesn't require calling again then use this flow */ if (state == WOLF_EVENT_STATE_DONE) { if (callAgain) { - /* needs called again, so allow it and handle completion in bench_async_handle */ + /* needs called again, so allow it and handle completion in + * bench_async_handle */ allowNext = 1; } else { @@ -1369,7 +1404,9 @@ static const char* bench_result_words2[][5] = { #define AES_AAD_OPTIONS_DEFAULT 0x3U #endif #endif - #define AES_AAD_STRING(s) (aesAuthAddSz == 0 ? (s "-no_AAD") : (aesAuthAddSz == AES_AUTH_ADD_SZ ? (s) : (s "-custom"))) + #define AES_AAD_STRING(s) \ + (aesAuthAddSz == 0 ? (s "-no_AAD") : \ + (aesAuthAddSz == AES_AUTH_ADD_SZ ? (s) : (s "-custom"))) enum en_aad_options { AAD_SIZE_DEFAULT = 0x1U, AAD_SIZE_ZERO = 0x2U, @@ -1643,8 +1680,7 @@ typedef enum bench_stat_type { PTHREAD_CHECK_RET(pthread_mutex_unlock(&bench_lock)); } -#else /* !WC_ENABLE_BENCH_THREADING */ - +#elif defined(WC_BENCH_TRACK_STATS) typedef struct bench_stats { const char* algo; const char* desc; @@ -1654,8 +1690,10 @@ typedef enum bench_stat_type { bench_stat_type_t type; int ret; } bench_stats_t; - /* 16 threads and 8 different operations. */ - #define MAX_BENCH_STATS (16 * 8) + /* Maximum number of stats to record */ + #ifndef MAX_BENCH_STATS + #define MAX_BENCH_STATS (128) + #endif static bench_stats_t gStats[MAX_BENCH_STATS]; static int gStatsCount; @@ -1726,10 +1764,11 @@ static WC_INLINE void bench_stats_start(int* count, double* start) } #ifdef WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS - #define bench_stats_start(count, start) do { \ - SAVE_VECTOR_REGISTERS(pr_err("SAVE_VECTOR_REGISTERS failed for benchmark run."); \ - return; ); \ - bench_stats_start(count, start); \ + #define bench_stats_start(count, start) do { \ + SAVE_VECTOR_REGISTERS(pr_err( \ + "SAVE_VECTOR_REGISTERS failed for benchmark run."); \ + return; ); \ + bench_stats_start(count, start); \ } while (0) #endif @@ -1832,7 +1871,7 @@ static void bench_stats_sym_finish(const char* desc, int useDeviceID, { double total, persec = 0, blocks = (double)count; const char* blockType; - char msg[__BENCHMARK_MAXIMUM_LINE_LENGTH]; + char msg[WC_BENCH_MAX_LINE_LEN]; const char** word = bench_result_words1[lng_index]; static int sym_header_printed = 0; @@ -1922,9 +1961,11 @@ static void bench_stats_sym_finish(const char* desc, int useDeviceID, /* note this codepath brings in all the fields from the non-CSV case. */ #ifdef WOLFSSL_ESPIDF #ifdef HAVE_GET_CYCLES - (void)XSNPRINTF(msg, sizeof(msg), "sym,%s,%s,%lu," FLT_FMT "," FLT_FMT ",%lu,", desc, + (void)XSNPRINTF(msg, sizeof(msg), + "sym,%s,%s,%lu," FLT_FMT "," FLT_FMT ",%lu,", desc, BENCH_DEVID_GET_NAME(useDeviceID), - bytes_processed, FLT_FMT_ARGS(total), FLT_FMT_ARGS(persec), + bytes_processed, FLT_FMT_ARGS(total), + FLT_FMT_ARGS(persec), (long unsigned int) total_cycles); #else #warning "HAVE_GET_CYCLES should be defined for WOLFSSL_ESPIDF" @@ -1949,9 +1990,10 @@ static void bench_stats_sym_finish(const char* desc, int useDeviceID, #endif #elif defined(BENCH_DEVID) (void)XSNPRINTF(msg, sizeof(msg), "%s,%s," FLT_FMT ",", desc, - BENCH_DEVID_GET_NAME(useDeviceID), FLT_FMT_ARGS(persec)); + BENCH_DEVID_GET_NAME(useDeviceID), FLT_FMT_ARGS(persec)); #else - (void)XSNPRINTF(msg, sizeof(msg), "%s," FLT_FMT ",", desc, FLT_FMT_ARGS(persec)); + (void)XSNPRINTF(msg, sizeof(msg), "%s," FLT_FMT ",", desc, + FLT_FMT_ARGS(persec)); #endif #ifdef WOLFSSL_ESPIDF @@ -2014,9 +2056,11 @@ static void bench_stats_sym_finish(const char* desc, int useDeviceID, XFFLUSH(stdout); #endif +#if defined(WC_ENABLE_BENCH_THREADING) || defined(WC_BENCH_TRACK_STATS) /* Add to thread stats */ bench_stats_add(BENCH_STAT_SYM, desc, 0, desc, useDeviceID, persec, blockType, ret); +#endif (void)useDeviceID; (void)ret; @@ -2037,7 +2081,9 @@ static void bench_stats_asym_finish_ex(const char* algo, int strength, { double total, each = 0, opsSec, milliEach; const char **word = bench_result_words2[lng_index]; +#if defined(WC_ENABLE_BENCH_THREADING) || defined(WC_BENCH_TRACK_STATS) const char* kOpsSec = "Ops/Sec"; +#endif char msg[256]; static int asym_header_printed = 0; @@ -2098,22 +2144,27 @@ static void bench_stats_asym_finish_ex(const char* algo, int strength, #ifdef GENERATE_MACHINE_PARSEABLE_REPORT #ifdef HAVE_GET_CYCLES (void)XSNPRINTF(msg, sizeof(msg), - "asym,%s,%d,%s%s," FLT_FMT_PREC "," FLT_FMT_PREC ",%d," FLT_FMT - ",%lu," FLT_FMT_PREC "\n", - algo, strength, desc, desc_extra, FLT_FMT_PREC_ARGS(3, milliEach), + "asym,%s,%d,%s%s," FLT_FMT_PREC "," FLT_FMT_PREC ",%d," + FLT_FMT ",%lu," FLT_FMT_PREC "\n", + algo, strength, desc, desc_extra, + FLT_FMT_PREC_ARGS(3, milliEach), FLT_FMT_PREC_ARGS(3, opsSec), - count, FLT_FMT_ARGS(total), (unsigned long) total_cycles, - FLT_FMT_PREC_ARGS(6, (double)total_cycles / (double)count)); + count, FLT_FMT_ARGS(total), (unsigned long)total_cycles, + FLT_FMT_PREC_ARGS(6, + (double)total_cycles / (double)count)); #else (void)XSNPRINTF(msg, sizeof(msg), - "asym,%s,%d,%s%s," FLT_FMT_PREC "," FLT_FMT_PREC ",%d," FLT_FMT "\n", - algo, strength, desc, desc_extra, FLT_FMT_PREC_ARGS(3, milliEach), + "asym,%s,%d,%s%s," FLT_FMT_PREC "," FLT_FMT_PREC ",%d," + FLT_FMT "\n", + algo, strength, desc, desc_extra, + FLT_FMT_PREC_ARGS(3, milliEach), FLT_FMT_PREC_ARGS(3, opsSec), count, FLT_FMT_ARGS(total)); #endif #else - (void)XSNPRINTF(msg, sizeof(msg), "%s,%d,%s%s," FLT_FMT_PREC "," FLT_FMT_PREC ",\n", algo, - strength, desc, desc_extra, FLT_FMT_PREC_ARGS(3, milliEach), + (void)XSNPRINTF(msg, sizeof(msg), "%s,%d,%s%s," FLT_FMT_PREC "," + FLT_FMT_PREC ",\n", algo, strength, desc, desc_extra, + FLT_FMT_PREC_ARGS(3, milliEach), FLT_FMT_PREC_ARGS(3, opsSec)); #endif } /* if (csv_format == 1) */ @@ -2122,28 +2173,33 @@ static void bench_stats_asym_finish_ex(const char* algo, int strength, #ifdef GENERATE_MACHINE_PARSEABLE_REPORT #ifdef HAVE_GET_CYCLES (void)XSNPRINTF(msg, sizeof(msg), - "%-6s %5d %8s%-2s %s %6d %s " FLT_FMT_PREC2 " %s, %s " FLT_FMT_PREC2 " ms," - " " FLT_FMT_PREC " %s, %lu cycles\n", algo, strength, desc, - desc_extra, BENCH_DEVID_GET_NAME(useDeviceID), - count, word[0], FLT_FMT_PREC2_ARGS(5, 3, total), word[1], word[2], + "%-6s %5d %8s%-2s %s %6d %s " FLT_FMT_PREC2 " %s, %s " + FLT_FMT_PREC2 " ms, " FLT_FMT_PREC " %s, %lu cycles\n", + algo, strength, desc, desc_extra, + BENCH_DEVID_GET_NAME(useDeviceID), count, word[0], + FLT_FMT_PREC2_ARGS(5, 3, total), word[1], word[2], FLT_FMT_PREC2_ARGS(5, 3, milliEach), - FLT_FMT_PREC_ARGS(3, opsSec), word[3], (unsigned long) total_cycles); + FLT_FMT_PREC_ARGS(3, opsSec), word[3], + (unsigned long)total_cycles); #else (void)XSNPRINTF(msg, sizeof(msg), - "%-6s %5d %8s%-2s %s %6d %s " FLT_FMT_PREC2 " %s, %s " FLT_FMT_PREC2 " ms," - " " FLT_FMT_PREC " %s\n", algo, strength, desc, - desc_extra, BENCH_DEVID_GET_NAME(useDeviceID), - count, word[0], FLT_FMT_PREC2_ARGS(5, 3, total), word[1], word[2], + "%-6s %5d %8s%-2s %s %6d %s " FLT_FMT_PREC2 " %s, %s " + FLT_FMT_PREC2 " ms, " FLT_FMT_PREC " %s\n", + algo, strength, desc, desc_extra, + BENCH_DEVID_GET_NAME(useDeviceID), count, word[0], + FLT_FMT_PREC2_ARGS(5, 3, total), word[1], word[2], FLT_FMT_PREC2_ARGS(5, 3, milliEach), FLT_FMT_PREC_ARGS(3, opsSec), word[3]); #endif /* HAVE_GET_CYCLES */ #else (void)XSNPRINTF(msg, sizeof(msg), - "%-6s %5d %8s%-2s %s %6d %s " FLT_FMT_PREC2 " %s, %s " FLT_FMT_PREC2 " ms," - " " FLT_FMT_PREC " %s\n", algo, strength, desc, desc_extra, + "%-6s %5d %8s%-2s %s %6d %s " FLT_FMT_PREC2 " %s, %s " + FLT_FMT_PREC2 " ms, " FLT_FMT_PREC " %s\n", + algo, strength, desc, desc_extra, BENCH_DEVID_GET_NAME(useDeviceID), count, word[0], FLT_FMT_PREC2_ARGS(5, 3, total), word[1], word[2], - FLT_FMT_PREC2_ARGS(5, 3, milliEach), FLT_FMT_PREC_ARGS(3, opsSec), word[3]); + FLT_FMT_PREC2_ARGS(5, 3, milliEach), + FLT_FMT_PREC_ARGS(3, opsSec), word[3]); #endif } printf("%s", msg); @@ -2158,9 +2214,11 @@ static void bench_stats_asym_finish_ex(const char* algo, int strength, XFFLUSH(stdout); #endif +#if defined(WC_ENABLE_BENCH_THREADING) || defined(WC_BENCH_TRACK_STATS) /* Add to thread stats */ bench_stats_add(BENCH_STAT_ASYM, algo, strength, desc, useDeviceID, opsSec, kOpsSec, ret); +#endif (void)useDeviceID; (void)ret; @@ -3004,7 +3062,7 @@ int benchmark_free(void) { int ret; -#ifdef WC_ENABLE_BENCH_THREADING +#if defined(WC_ENABLE_BENCH_THREADING) || defined(WC_BENCH_TRACK_STATS) if (gPrintStats || devId != INVALID_DEVID) { bench_stats_print(); }