forked from wolfSSL/wolfssl
Merge pull request #5967 from dgarske/bench_help
Fixes for benchmark help `-alg` list and block format
This commit is contained in:
@ -1666,43 +1666,36 @@ static WC_INLINE int bench_stats_check(double start)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* return text for units and scale the value of blocks as needed for base2 */
|
/* return text for units and scale the value of blocks as needed for base2 */
|
||||||
static WC_INLINE const char* specified_base2_blockType(double * blocks)
|
static const char* get_blocktype_base10(double* blocks)
|
||||||
{
|
{
|
||||||
const char* rt;
|
const char* rt;
|
||||||
|
|
||||||
#if ( defined(WOLFSSL_BENCHMARK_FIXED_UNITS_G) \
|
#if ( defined(WOLFSSL_BENCHMARK_FIXED_UNITS_G) || \
|
||||||
|| defined(WOLFSSL_BENCHMARK_FIXED_UNITS_GB) )
|
defined(WOLFSSL_BENCHMARK_FIXED_UNITS_GB))
|
||||||
#undef WOLFSSL_FIXED_UNITS_PER_SEC
|
#undef WOLFSSL_FIXED_UNITS_PER_SEC
|
||||||
#define WOLFSSL_FIXED_UNITS_PER_SEC "GB/s"
|
#define WOLFSSL_FIXED_UNITS_PER_SEC "GB/s"
|
||||||
*blocks /= (1000UL * 1000UL * 1000UL);
|
*blocks /= (1000UL * 1000UL * 1000UL);
|
||||||
rt = "GiB";
|
rt = "GiB";
|
||||||
|
#elif (defined(WOLFSSL_BENCHMARK_FIXED_UNITS_M) || \
|
||||||
#elif ( defined(WOLFSSL_BENCHMARK_FIXED_UNITS_M) \
|
defined(WOLFSSL_BENCHMARK_FIXED_UNITS_MB))
|
||||||
|| defined(WOLFSSL_BENCHMARK_FIXED_UNITS_MB) )
|
|
||||||
#undef WOLFSSL_FIXED_UNITS_PER_SEC
|
#undef WOLFSSL_FIXED_UNITS_PER_SEC
|
||||||
#define WOLFSSL_FIXED_UNITS_PER_SEC "MB/s"
|
#define WOLFSSL_FIXED_UNITS_PER_SEC "MB/s"
|
||||||
*blocks /= (1024UL * 1024UL);
|
*blocks /= (1024UL * 1024UL);
|
||||||
rt = "MiB";
|
rt = "MiB";
|
||||||
|
#elif (defined(WOLFSSL_BENCHMARK_FIXED_UNITS_K) || \
|
||||||
#elif ( defined (WOLFSSL_BENCHMARK_FIXED_UNITS_K) \
|
defined(WOLFSSL_BENCHMARK_FIXED_UNITS_KB))
|
||||||
|| defined (WOLFSSL_BENCHMARK_FIXED_UNITS_KB))
|
|
||||||
#undef WOLFSSL_FIXED_UNITS_PER_SEC
|
#undef WOLFSSL_FIXED_UNITS_PER_SEC
|
||||||
#define WOLFSSL_FIXED_UNITS_PER_SEC "KB/s"
|
#define WOLFSSL_FIXED_UNITS_PER_SEC "KB/s"
|
||||||
*blocks /= 1024;
|
*blocks /= 1024;
|
||||||
rt = "KiB";
|
rt = "KiB";
|
||||||
|
#elif defined (WOLFSSL_BENCHMARK_FIXED_UNITS_B)
|
||||||
#elif ( defined (WOLFSSL_BENCHMARK_FIXED_UNITS_B) )
|
|
||||||
#undef WOLFSSL_FIXED_UNITS_PER_SEC
|
#undef WOLFSSL_FIXED_UNITS_PER_SEC
|
||||||
#define WOLFSSL_FIXED_UNITS_PER_SEC "bytes/s"
|
#define WOLFSSL_FIXED_UNITS_PER_SEC "bytes/s"
|
||||||
(void)(*blocks); /* no adjustment, just appease compiler for not used */
|
(void)(*blocks); /* no adjustment, just appease compiler for not used */
|
||||||
rt = "bytes";
|
rt = "bytes";
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
/* If no user-specified, auto-scale each metric (results vary).
|
||||||
/* if no user-specified, auto-scale each metric (results vary)
|
* Determine if we should show as KB or MB or bytes. No GiB here. */
|
||||||
**
|
|
||||||
** determine if we should show as KB or MB or bytes. No GiB here.
|
|
||||||
*/
|
|
||||||
if (*blocks > (1024UL * 1024UL)) {
|
if (*blocks > (1024UL * 1024UL)) {
|
||||||
*blocks /= (1024UL * 1024UL);
|
*blocks /= (1024UL * 1024UL);
|
||||||
rt = "MiB";
|
rt = "MiB";
|
||||||
@ -1714,56 +1707,49 @@ static WC_INLINE const char* specified_base2_blockType(double * blocks)
|
|||||||
else {
|
else {
|
||||||
rt = "bytes";
|
rt = "bytes";
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return rt;
|
return rt;
|
||||||
} /* specified_base2_blockType() */
|
}
|
||||||
|
|
||||||
/* return text for units and scale the value of blocks as needed */
|
/* return text for units and scale the value of blocks as needed */
|
||||||
static WC_INLINE const char* specified_blockType(double * blocks)
|
static const char* get_blocktype(double* blocks)
|
||||||
{
|
{
|
||||||
const char* rt;
|
const char* rt;
|
||||||
|
|
||||||
#if ( defined(WOLFSSL_BENCHMARK_FIXED_UNITS_G) \
|
#if ( defined(WOLFSSL_BENCHMARK_FIXED_UNITS_G) || \
|
||||||
|| defined(WOLFSSL_BENCHMARK_FIXED_UNITS_GB) )
|
defined(WOLFSSL_BENCHMARK_FIXED_UNITS_GB))
|
||||||
*blocks /= (1000UL * 1000UL * 1000UL);
|
*blocks /= (1000UL * 1000UL * 1000UL);
|
||||||
rt = "GB";
|
rt = "GB";
|
||||||
|
#elif (defined(WOLFSSL_BENCHMARK_FIXED_UNITS_M) || \
|
||||||
#elif ( defined(WOLFSSL_BENCHMARK_FIXED_UNITS_M) \
|
defined(WOLFSSL_BENCHMARK_FIXED_UNITS_MB))
|
||||||
|| defined(WOLFSSL_BENCHMARK_FIXED_UNITS_MB) )
|
|
||||||
*blocks /= (1000UL * 1000UL);
|
*blocks /= (1000UL * 1000UL);
|
||||||
rt = "MB";
|
rt = "MB";
|
||||||
|
#elif (defined(WOLFSSL_BENCHMARK_FIXED_UNITS_K) || \
|
||||||
#elif ( defined (WOLFSSL_BENCHMARK_FIXED_UNITS_K) \
|
defined(WOLFSSL_BENCHMARK_FIXED_UNITS_KB))
|
||||||
|| defined (WOLFSSL_BENCHMARK_FIXED_UNITS_KB) )
|
|
||||||
*blocks /= (1000UL);
|
*blocks /= (1000UL);
|
||||||
rt = "KB";
|
rt = "KB";
|
||||||
|
#elif defined (WOLFSSL_BENCHMARK_FIXED_UNITS_B)
|
||||||
#elif ( defined (WOLFSSL_BENCHMARK_FIXED_UNITS_B) )
|
|
||||||
(void)(*blocks); /* no adjustment, just appease compiler */
|
(void)(*blocks); /* no adjustment, just appease compiler */
|
||||||
rt = "bytes";
|
rt = "bytes";
|
||||||
|
|
||||||
#else
|
#else
|
||||||
/* if not user-specified, auto-scale each metric (results vary)
|
/* If not user-specified, auto-scale each metric (results vary).
|
||||||
**
|
* Determine if we should show as KB or MB or bytes */
|
||||||
** determine if we should show as KB or MB or bytes
|
if (*blocks > (1000UL * 1000UL)) {
|
||||||
*/
|
*blocks /= (1000UL * 1000UL);
|
||||||
if (*blocks > (1000UL * 1000UL)) {
|
rt = "MB";
|
||||||
*blocks /= (1000UL * 1000UL);
|
}
|
||||||
rt = "MB";
|
else if (*blocks > 1000) {
|
||||||
}
|
*blocks /= 1000; /* make KB */
|
||||||
else if (*blocks > 1000) {
|
rt = "KB";
|
||||||
*blocks /= 1000; /* make KB */
|
}
|
||||||
rt = "KB";
|
else {
|
||||||
}
|
rt = "bytes";
|
||||||
else {
|
}
|
||||||
rt = "bytes";
|
#endif
|
||||||
} /* rt auto-assigned */
|
|
||||||
#endif /* WOLFSSL_BENCHMARK UNITS */
|
|
||||||
|
|
||||||
return rt;
|
return rt;
|
||||||
} /* specified_blockType */
|
}
|
||||||
|
|
||||||
/* countSz is number of bytes that 1 count represents. Normally bench_size,
|
/* countSz is number of bytes that 1 count represents. Normally bench_size,
|
||||||
* except for AES direct that operates on AES_BLOCK_SIZE blocks */
|
* except for AES direct that operates on AES_BLOCK_SIZE blocks */
|
||||||
@ -1825,14 +1811,14 @@ static void bench_stats_sym_finish(const char* desc, int useDeviceID,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* determine if we have fixed units, or auto-scale bits or bytes for units.
|
/* determine if we have fixed units, or auto-scale bits or bytes for units.
|
||||||
** note that the blockType text is assigned AND the blocks param is scaled.
|
* note that the blockType text is assigned AND the blocks param is scaled.
|
||||||
*/
|
*/
|
||||||
if (base2) {
|
if (base2) {
|
||||||
blockType = specified_base2_blockType(&blocks);
|
blockType = get_blocktype(&blocks);
|
||||||
} /* is base2 bit counter */
|
}
|
||||||
else {
|
else {
|
||||||
blockType = specified_blockType(&blocks);
|
blockType = get_blocktype_base10(&blocks);
|
||||||
} /* not base2, is byte counter */
|
}
|
||||||
|
|
||||||
/* calculate blocks per second */
|
/* calculate blocks per second */
|
||||||
if (total > 0) {
|
if (total > 0) {
|
||||||
@ -8576,16 +8562,22 @@ void benchmark_configure(int block_size)
|
|||||||
* str Algorithm string to print.
|
* str Algorithm string to print.
|
||||||
* line Length of line used so far.
|
* line Length of line used so far.
|
||||||
*/
|
*/
|
||||||
|
#ifndef BENCH_MAX_LINE
|
||||||
|
#define BENCH_MAX_LINE 80
|
||||||
|
#endif
|
||||||
static void print_alg(const char* str, int* line)
|
static void print_alg(const char* str, int* line)
|
||||||
{
|
{
|
||||||
int optLen;
|
const char* const ident = " ";
|
||||||
|
if (*line == 0) {
|
||||||
optLen = (int)XSTRLEN(str) + 1;
|
fputs(ident, stdout);
|
||||||
if (optLen + *line > 80) {
|
*line = (int)XSTRLEN(ident);
|
||||||
printf("\n ");
|
}
|
||||||
*line = 13;
|
printf(" %s", str);
|
||||||
|
*line += (int)XSTRLEN(str) + 1;
|
||||||
|
if (*line > BENCH_MAX_LINE) {
|
||||||
|
printf("\n");
|
||||||
|
*line = 0;
|
||||||
}
|
}
|
||||||
*line += optLen;
|
|
||||||
}
|
}
|
||||||
#endif /* WOLFSSL_BENCHMARK_ALL */
|
#endif /* WOLFSSL_BENCHMARK_ALL */
|
||||||
|
|
||||||
@ -8645,37 +8637,26 @@ static void Usage(void)
|
|||||||
e++;
|
e++;
|
||||||
#ifndef WOLFSSL_BENCHMARK_ALL
|
#ifndef WOLFSSL_BENCHMARK_ALL
|
||||||
printf("%s", bench_Usage_msg1[lng_index][e]); /* option -<alg> */
|
printf("%s", bench_Usage_msg1[lng_index][e]); /* option -<alg> */
|
||||||
printf(" ");
|
line = 0;
|
||||||
line = 13;
|
|
||||||
for (i=0; bench_cipher_opt[i].str != NULL; i++)
|
for (i=0; bench_cipher_opt[i].str != NULL; i++)
|
||||||
print_alg(bench_cipher_opt[i].str + 1, &line);
|
print_alg(bench_cipher_opt[i].str, &line);
|
||||||
printf("\n ");
|
|
||||||
line = 13;
|
|
||||||
for (i=0; bench_digest_opt[i].str != NULL; i++)
|
for (i=0; bench_digest_opt[i].str != NULL; i++)
|
||||||
print_alg(bench_digest_opt[i].str + 1, &line);
|
print_alg(bench_digest_opt[i].str, &line);
|
||||||
printf("\n ");
|
|
||||||
line = 13;
|
|
||||||
for (i=0; bench_mac_opt[i].str != NULL; i++)
|
for (i=0; bench_mac_opt[i].str != NULL; i++)
|
||||||
print_alg(bench_mac_opt[i].str + 1, &line);
|
print_alg(bench_mac_opt[i].str, &line);
|
||||||
printf("\n ");
|
|
||||||
line = 13;
|
|
||||||
for (i=0; bench_asym_opt[i].str != NULL; i++)
|
for (i=0; bench_asym_opt[i].str != NULL; i++)
|
||||||
print_alg(bench_asym_opt[i].str + 1, &line);
|
print_alg(bench_asym_opt[i].str, &line);
|
||||||
printf("\n ");
|
|
||||||
line = 13;
|
|
||||||
for (i=0; bench_other_opt[i].str != NULL; i++)
|
for (i=0; bench_other_opt[i].str != NULL; i++)
|
||||||
print_alg(bench_other_opt[i].str + 1, &line);
|
print_alg(bench_other_opt[i].str, &line);
|
||||||
printf("\n ");
|
|
||||||
#if defined(HAVE_PQC) && defined(HAVE_LIBOQS)
|
#if defined(HAVE_PQC) && defined(HAVE_LIBOQS)
|
||||||
line = 13;
|
|
||||||
for (i=0; bench_pq_asym_opt[i].str != NULL; i++)
|
for (i=0; bench_pq_asym_opt[i].str != NULL; i++)
|
||||||
print_alg(bench_pq_asym_opt[i].str + 1, &line);
|
print_alg(bench_pq_asym_opt[i].str, &line);
|
||||||
#if defined(HAVE_LIBOQS)
|
#if defined(HAVE_LIBOQS)
|
||||||
for (i=0; bench_pq_asym_opt2[i].str != NULL; i++)
|
for (i=0; bench_pq_asym_opt2[i].str != NULL; i++)
|
||||||
print_alg(bench_pq_asym_opt2[i].str + 1, &line);
|
print_alg(bench_pq_asym_opt2[i].str, &line);
|
||||||
printf("\n");
|
|
||||||
#endif /* HAVE_LIBOQS */
|
#endif /* HAVE_LIBOQS */
|
||||||
#endif /* HAVE_PQC */
|
#endif /* HAVE_PQC */
|
||||||
|
printf("\n");
|
||||||
#endif /* !WOLFSSL_BENCHMARK_ALL */
|
#endif /* !WOLFSSL_BENCHMARK_ALL */
|
||||||
e++;
|
e++;
|
||||||
printf("%s", bench_Usage_msg1[lng_index][e++]); /* option -lng */
|
printf("%s", bench_Usage_msg1[lng_index][e++]); /* option -lng */
|
||||||
|
Reference in New Issue
Block a user