summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/benchmark-cipher.c41
-rw-r--r--src/benchmark-tls.c62
-rw-r--r--src/benchmark.c8
-rw-r--r--src/benchmark.h2
4 files changed, 60 insertions, 53 deletions
diff --git a/src/benchmark-cipher.c b/src/benchmark-cipher.c
index d5bb7c9e7a..68573b687b 100644
--- a/src/benchmark-cipher.c
+++ b/src/benchmark-cipher.c
@@ -69,8 +69,8 @@ cipher_mac_bench (int algo, int mac_algo, int size)
key.data = _key;
key.size = keysize;
- printf ("Checking %s with %s (%dkb payload)...\n", gnutls_cipher_get_name (algo),
- gnutls_mac_get_name(mac_algo), size);
+ printf ("%16s-%s ", gnutls_cipher_get_name (algo),
+ gnutls_mac_get_name(mac_algo));
fflush (stdout);
start_benchmark(&st);
@@ -102,12 +102,11 @@ cipher_mac_bench (int algo, int mac_algo, int size)
gnutls_cipher_deinit (ctx);
gnutls_hmac_deinit(mac_ctx, NULL);
- stop_benchmark (&st, NULL);
+ stop_benchmark (&st, NULL, 1);
leave:
free (_key);
free (_iv);
-
}
@@ -140,8 +139,7 @@ cipher_bench (int algo, int size, int aead)
key.data = _key;
key.size = keysize;
- printf ("Checking %s (%dkb payload)...\n", gnutls_cipher_get_name (algo),
- size);
+ printf ("%16s ", gnutls_cipher_get_name (algo));
fflush (stdout);
start_benchmark(&st);
@@ -165,7 +163,7 @@ cipher_bench (int algo, int size, int aead)
gnutls_cipher_deinit (ctx);
- stop_benchmark(&st, NULL);
+ stop_benchmark(&st, NULL, 1);
leave:
free (_key);
@@ -185,7 +183,7 @@ mac_bench (int algo, int size)
return;
memset (_key, 0xf0, blocksize);
- printf ("Checking %s (%dkb payload)...\n", gnutls_mac_get_name (algo), size);
+ printf ("%16s ", gnutls_mac_get_name (algo));
fflush (stdout);
start_benchmark(&st);
@@ -197,7 +195,7 @@ mac_bench (int algo, int size)
}
while (benchmark_must_finish == 0);
- stop_benchmark(&st, NULL);
+ stop_benchmark(&st, NULL, 1);
free (_key);
}
@@ -206,28 +204,31 @@ void benchmark_cipher (int init, int debug_level)
{
gnutls_global_set_log_function (tls_log_func);
gnutls_global_set_log_level (debug_level);
+ int size = 16;
+
if (init)
{
gnutls_global_init ();
gnutls_rnd( GNUTLS_RND_NONCE, data, sizeof(data));
}
- cipher_mac_bench ( GNUTLS_CIPHER_SALSA20_256, GNUTLS_MAC_SHA1, 16);
- cipher_mac_bench ( GNUTLS_CIPHER_AES_128_CBC, GNUTLS_MAC_SHA1, 16);
- cipher_mac_bench ( GNUTLS_CIPHER_AES_128_CBC, GNUTLS_MAC_SHA256, 16);
- cipher_bench ( GNUTLS_CIPHER_AES_128_GCM, 16, 1);
+ printf("Checking ciphers, payload size: %u\n", size*1024);
+ cipher_mac_bench ( GNUTLS_CIPHER_SALSA20_256, GNUTLS_MAC_SHA1, size);
+ cipher_mac_bench ( GNUTLS_CIPHER_AES_128_CBC, GNUTLS_MAC_SHA1, size);
+ cipher_mac_bench ( GNUTLS_CIPHER_AES_128_CBC, GNUTLS_MAC_SHA256, size);
+ cipher_bench ( GNUTLS_CIPHER_AES_128_GCM, size, 1);
- mac_bench (GNUTLS_MAC_SHA1, 16);
- mac_bench (GNUTLS_MAC_SHA256, 16);
- mac_bench (GNUTLS_MAC_SHA512, 16);
+ mac_bench (GNUTLS_MAC_SHA1, size);
+ mac_bench (GNUTLS_MAC_SHA256, size);
+ mac_bench (GNUTLS_MAC_SHA512, size);
- cipher_bench (GNUTLS_CIPHER_3DES_CBC, 16, 0);
+ cipher_bench (GNUTLS_CIPHER_3DES_CBC, size, 0);
- cipher_bench (GNUTLS_CIPHER_AES_128_CBC, 16, 0);
+ cipher_bench (GNUTLS_CIPHER_AES_128_CBC, size, 0);
- cipher_bench (GNUTLS_CIPHER_ARCFOUR, 16, 0);
+ cipher_bench (GNUTLS_CIPHER_ARCFOUR, size, 0);
- cipher_bench ( GNUTLS_CIPHER_SALSA20_256, 16, 0);
+ cipher_bench ( GNUTLS_CIPHER_SALSA20_256, size, 0);
gnutls_global_deinit();
}
diff --git a/src/benchmark-tls.c b/src/benchmark-tls.c
index 84bbb87e26..96d1f9b243 100644
--- a/src/benchmark-tls.c
+++ b/src/benchmark-tls.c
@@ -234,10 +234,10 @@ static void test_ciphersuite(const char *cipher_prio, int size)
HANDSHAKE(client, server);
- fprintf(stdout, "Testing %s with %d packet size...\n",
+ fprintf(stdout, "%38s ",
gnutls_cipher_suite_get_name(gnutls_kx_get(server),
gnutls_cipher_get(server),
- gnutls_mac_get(server)), size);
+ gnutls_mac_get(server)));
fflush(stdout);
gnutls_rnd(GNUTLS_RND_NONCE, buffer, sizeof(buffer));
@@ -269,8 +269,7 @@ static void test_ciphersuite(const char *cipher_prio, int size)
}
while (benchmark_must_finish == 0);
- stop_benchmark(&st, NULL);
- fprintf(stdout, "\n");
+ stop_benchmark(&st, NULL, 1);
gnutls_bye(client, GNUTLS_SHUT_WR);
gnutls_bye(server, GNUTLS_SHUT_WR);
@@ -415,13 +414,13 @@ static void test_ciphersuite_kx(const char *cipher_prio)
}
while (benchmark_must_finish == 0);
- fprintf(stdout, "Benchmarked %s.\n", suite);
- stop_benchmark(&st, "transactions");
+ fprintf(stdout, "%38s ", suite);
+ stop_benchmark(&st, "transactions", 1);
avg = calc_avg(diffs, diffs_size);
sstddev = calc_sstdev(diffs, diffs_size, avg);
- printf(" Average handshake time: %.2f ms, sample variance: %.2f\n\n", avg, sstddev);
+ printf("%32s %.2f ms, sample variance: %.2f)\n", "(avg. handshake time:", avg, sstddev);
gnutls_anon_free_client_credentials(c_anoncred);
gnutls_anon_free_server_credentials(s_anoncred);
@@ -432,37 +431,42 @@ static void test_ciphersuite_kx(const char *cipher_prio)
void benchmark_tls(int debug_level, int ciphers)
{
+ int size;
+
gnutls_global_set_log_function(tls_log_func);
gnutls_global_set_log_level(debug_level);
gnutls_global_init();
if (ciphers != 0)
{
- printf("Testing throughput in cipher/MAC combinations:\n\n");
-
- test_ciphersuite(PRIO_SALSA20_256_UMAC_96, 1400);
- test_ciphersuite(PRIO_SALSA20_256_SHA1, 1400);
- test_ciphersuite(PRIO_ESTREAM_SALSA20_256_UMAC_96, 1400);
- test_ciphersuite(PRIO_ESTREAM_SALSA20_256_SHA1, 1400);
- test_ciphersuite(PRIO_ARCFOUR_128_SHA1, 1400);
- test_ciphersuite(PRIO_ARCFOUR_128_MD5, 1400);
- test_ciphersuite(PRIO_AES_GCM, 1400);
- test_ciphersuite(PRIO_AES_CBC_SHA1, 1400);
- test_ciphersuite(PRIO_CAMELLIA_CBC_SHA1, 1400);
-
- test_ciphersuite(PRIO_SALSA20_256_UMAC_96, 15 * 1024);
- test_ciphersuite(PRIO_SALSA20_256_SHA1, 15*1024);
- test_ciphersuite(PRIO_ESTREAM_SALSA20_256_UMAC_96, 15 * 1024);
- test_ciphersuite(PRIO_ESTREAM_SALSA20_256_SHA1, 15*1024);
- test_ciphersuite(PRIO_ARCFOUR_128_SHA1, 15 * 1024);
- test_ciphersuite(PRIO_ARCFOUR_128_MD5, 15 * 1024);
- test_ciphersuite(PRIO_AES_GCM, 15 * 1024);
- test_ciphersuite(PRIO_AES_CBC_SHA1, 15 * 1024);
- test_ciphersuite(PRIO_CAMELLIA_CBC_SHA1, 15 * 1024);
+ size = 1400;
+ printf("Testing throughput in cipher/MAC combinations (payload: %d bytes)\n", size);
+
+ test_ciphersuite(PRIO_SALSA20_256_UMAC_96, size);
+ test_ciphersuite(PRIO_SALSA20_256_SHA1, size);
+ test_ciphersuite(PRIO_ESTREAM_SALSA20_256_UMAC_96, size);
+ test_ciphersuite(PRIO_ESTREAM_SALSA20_256_SHA1, size);
+ test_ciphersuite(PRIO_ARCFOUR_128_SHA1, size);
+ test_ciphersuite(PRIO_ARCFOUR_128_MD5, size);
+ test_ciphersuite(PRIO_AES_GCM, size);
+ test_ciphersuite(PRIO_AES_CBC_SHA1, size);
+ test_ciphersuite(PRIO_CAMELLIA_CBC_SHA1, size);
+
+ size = 15*1024;
+ printf("\nTesting throughput in cipher/MAC combinations (payload: %d bytes)\n", size);
+ test_ciphersuite(PRIO_SALSA20_256_UMAC_96, size);
+ test_ciphersuite(PRIO_SALSA20_256_SHA1, size);
+ test_ciphersuite(PRIO_ESTREAM_SALSA20_256_UMAC_96, size);
+ test_ciphersuite(PRIO_ESTREAM_SALSA20_256_SHA1, size);
+ test_ciphersuite(PRIO_ARCFOUR_128_SHA1, size);
+ test_ciphersuite(PRIO_ARCFOUR_128_MD5, size);
+ test_ciphersuite(PRIO_AES_GCM, size);
+ test_ciphersuite(PRIO_AES_CBC_SHA1, size);
+ test_ciphersuite(PRIO_CAMELLIA_CBC_SHA1, size);
}
else
{
- printf("\nTesting key exchanges (RSA/DH bits: %d, EC bits: %d):\n\n", rsa_bits, ec_bits);
+ printf("Testing key exchanges (RSA/DH bits: %d, EC bits: %d)\n", rsa_bits, ec_bits);
test_ciphersuite_kx(PRIO_DH);
test_ciphersuite_kx(PRIO_ECDH);
test_ciphersuite_kx(PRIO_ECDHE_ECDSA);
diff --git a/src/benchmark.c b/src/benchmark.c
index d65b6ab0bb..5f41535c1a 100644
--- a/src/benchmark.c
+++ b/src/benchmark.c
@@ -122,7 +122,7 @@ void start_benchmark(struct benchmark_st * st)
}
/* returns the elapsed time */
-double stop_benchmark(struct benchmark_st * st, const char* metric)
+double stop_benchmark(struct benchmark_st * st, const char* metric, int quiet)
{
double secs;
unsigned long lsecs;
@@ -149,14 +149,16 @@ double stop_benchmark(struct benchmark_st * st, const char* metric)
if (metric == NULL)
{ /* assume bytes/sec */
value2human (st->size, secs, &ddata, &dspeed, imetric);
- printf (" Processed %.2f %s in %.2f secs: ", ddata, imetric, secs);
+ if (quiet == 0)
+ printf (" Processed %.2f %s in %.2f secs: ", ddata, imetric, secs);
printf ("%.2f %s/sec\n", dspeed, imetric);
}
else
{
ddata = (double) st->size;
dspeed = ddata / secs;
- printf (" Processed %.2f %s in %.2f secs: ", ddata, metric, secs);
+ if (quiet == 0)
+ printf (" Processed %.2f %s in %.2f secs: ", ddata, metric, secs);
printf ("%.2f %s/sec\n", dspeed, metric);
}
diff --git a/src/benchmark.h b/src/benchmark.h
index bcc07c7dbf..059b477b84 100644
--- a/src/benchmark.h
+++ b/src/benchmark.h
@@ -45,7 +45,7 @@ struct benchmark_st
extern int benchmark_must_finish;
void start_benchmark(struct benchmark_st * st);
-double stop_benchmark(struct benchmark_st * st, const char* metric);
+double stop_benchmark(struct benchmark_st * st, const char* metric, int quiet);
inline static unsigned int
timespec_sub_ms (struct timespec *a, struct timespec *b)