Unbreak the performance tests.

This commit is contained in:
Dag-Erling Smørgrav 2014-07-10 13:30:48 +00:00 committed by des
parent b7c8a6f6ae
commit 6da2e5388a
2 changed files with 24 additions and 54 deletions

View file

@ -176,12 +176,13 @@ t_md5_vector(char **desc CRYB_UNUSED, void *arg)
*/
#define T_PERF_ITERATIONS 1000
static int
t_md5_perf(char **desc CRYB_UNUSED, void *arg)
t_md5_perf(char **desc, void *arg)
{
struct timespec ts, te;
unsigned long ns;
uint8_t digest[MD5_DIGEST_LEN];
char *msg, *comment;
size_t msglen = *(size_t *)arg;
if ((msg = calloc(1, msglen)) == NULL)
err(1, "calloc()");
@ -196,7 +197,7 @@ t_md5_perf(char **desc CRYB_UNUSED, void *arg)
msglen, T_PERF_ITERATIONS, ns);
if (comment == NULL)
err(1, "asprintf()");
*desc = (const char *)comment;
*desc = comment;
return (1);
}
#endif
@ -224,31 +225,6 @@ t_md5_short_updates(char **desc CRYB_UNUSED, void *arg)
}
#endif
#ifdef BENCHMARKS
/*
* Microbenchmarks
*/
int
t_md5_perf_0, "microbenchmark with empty message")
{
return (t_md5_perf(0, desc));
}
T_FUNC(perf_1000, "microbenchmark with 1,000-byte message")
{
return (t_md5_perf(1000, desc));
}
T_FUNC(perf_1000000, "microbenchmark with 1,000,000-byte message")
{
return (t_md5_perf(1000000, desc));
}
#endif
/***************************************************************************
* Boilerplate
@ -278,7 +254,15 @@ t_prepare(int argc, char *argv[])
*/
t_add_test(t_md5_short_updates, &t_md5_vectors[6],
"multiple short updates");
// t_add_test(t_md5_partial
#endif
#ifdef BENCHMARKS
static size_t one = 1, thousand = 1000, million = 1000000;
t_add_test(t_md5_perf, &one,
"performance test (1 byte)");
t_add_test(t_md5_perf, &thousand,
"performance test (1,000 bytes)");
t_add_test(t_md5_perf, &million,
"performance test (1,000,000 bytes)");
#endif
return (0);
}

View file

@ -196,12 +196,13 @@ t_sha1_short_updates(char **desc CRYB_UNUSED, void *arg)
*/
#define T_PERF_ITERATIONS 1000
static int
t_sha1_perf(const char **desc, void *arg)
t_sha1_perf(char **desc, void *arg)
{
struct timespec ts, te;
unsigned long ns;
uint8_t digest[SHA1_DIGEST_LEN];
char *msg, *comment;
size_t msglen = *(size_t *)arg;
if ((msg = calloc(1, msglen)) == NULL)
err(1, "calloc()");
@ -216,35 +217,11 @@ t_sha1_perf(const char **desc, void *arg)
msglen, T_PERF_ITERATIONS, ns);
if (comment == NULL)
err(1, "asprintf()");
*desc = (const char *)comment;
*desc = comment;
return (1);
}
#endif
#ifdef BENCHMARKS
/*
* Microbenchmarks
*/
T_FUNC(perf_0, "microbenchmark with empty message")
{
return (t_sha1_perf(0, desc));
}
T_FUNC(perf_1000, "microbenchmark with 1,000-byte message")
{
return (t_sha1_perf(1000, desc));
}
T_FUNC(perf_1000000, "microbenchmark with 1,000,000-byte message")
{
return (t_sha1_perf(1000000, desc));
}
#endif
/***************************************************************************
* Boilerplate
@ -274,6 +251,15 @@ t_prepare(int argc, char *argv[])
*/
t_add_test(t_sha1_short_updates, &t_sha1_vectors[4],
"multiple short updates");
#endif
#ifdef BENCHMARKS
static size_t one = 1, thousand = 1000, million = 1000000;
t_add_test(t_sha1_perf, &one,
"performance test (1 byte)");
t_add_test(t_sha1_perf, &thousand,
"performance test (1,000 bytes)");
t_add_test(t_sha1_perf, &million,
"performance test (1,000,000 bytes)");
#endif
return (0);
}