mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
Add a siphash benchmark.
This commit is contained in:
parent
0ad607d604
commit
e9c1c3ff7f
@ -337,6 +337,30 @@ bench_dmap(void)
|
||||
smartlist_free(sl2);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user