mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 18:57:27 +02:00
Fix for MB
vs MiB
printing. The base2
option was printing type backwards (base2=1
= 1024 bytes and base2=0
or -base10
means 1000 bytes).
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) {
|
||||||
@ -8583,7 +8569,7 @@ static void print_alg(const char* str, int* line)
|
|||||||
{
|
{
|
||||||
const char* const ident = " ";
|
const char* const ident = " ";
|
||||||
if (*line == 0) {
|
if (*line == 0) {
|
||||||
printf(ident);
|
fputs(ident, stdout);
|
||||||
*line = (int)XSTRLEN(ident);
|
*line = (int)XSTRLEN(ident);
|
||||||
}
|
}
|
||||||
printf(" %s", str);
|
printf(" %s", str);
|
||||||
|
Reference in New Issue
Block a user