aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-05-06 12:55:39 -0400
committerNick Mathewson <nickm@torproject.org>2014-05-06 12:55:39 -0400
commite9c1c3ff7f3123495493bad7aa77ef6194005c75 (patch)
tree21694d8e07c3939f2ad25d884e7dd8ff435c76a6 /src/test
parent0ad607d6042e59e8d63a32ddd98a6673ed5f79db (diff)
downloadtor-e9c1c3ff7f3123495493bad7aa77ef6194005c75.tar
tor-e9c1c3ff7f3123495493bad7aa77ef6194005c75.tar.gz
Add a siphash benchmark.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/bench.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/bench.c b/src/test/bench.c
index c9cc101b7..a3fa7fe31 100644
--- a/src/test/bench.c
+++ b/src/test/bench.c
@@ -338,6 +338,30 @@ bench_dmap(void)
}
static void
+bench_siphash(void)
+{
+ char buf[128];
+ int lens[] = { 7, 8, 15, 16, 20, 32, 111, 128, -1 };
+ int i, j;
+ uint64_t total;
+ uint64_t start, end;
+ const int N = 300000;
+ crypto_rand(buf, sizeof(buf));
+
+ for (i = 0; lens[i] > 0; ++i) {
+ total = 0;
+ reset_perftime();
+ start = perftime();
+ for (j = 0; j < N; ++j) {
+ total += siphash24g(buf, lens[i]);
+ }
+ end = perftime();
+ printf("siphash24g(%d): %.2f ns per call\n",
+ lens[i], NANOCOUNT(start,end,N));
+ }
+}
+
+static void
bench_cell_ops(void)
{
const int iters = 1<<16;
@@ -487,6 +511,7 @@ typedef struct benchmark_t {
static struct benchmark_t benchmarks[] = {
ENT(dmap),
+ ENT(siphash),
ENT(aes),
ENT(onion_TAP),
#ifdef CURVE25519_ENABLED