From fc2517947b83542cbb0d2109d8b22c5d70c9b49a Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Sun, 8 Jul 2012 14:33:50 -0400 Subject: [PATCH] regressions/ck_ht: Use user-specified hash function for direct benchmark. --- regressions/ck_ht/benchmark/parallel_direct.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/regressions/ck_ht/benchmark/parallel_direct.c b/regressions/ck_ht/benchmark/parallel_direct.c index 761bf47..5f05a8e 100644 --- a/regressions/ck_ht/benchmark/parallel_direct.c +++ b/regressions/ck_ht/benchmark/parallel_direct.c @@ -118,6 +118,17 @@ static struct ck_malloc my_allocator = { .free = ht_free }; +static void +hash_function(ck_ht_hash_t *h, const void *key, size_t key_length, uint64_t seed) +{ + const uintptr_t *value = key; + + (void)key_length; + (void)seed; + h->value = *value; + return; +} + static void table_init(void) { @@ -126,7 +137,7 @@ table_init(void) ck_epoch_register(&epoch_ht, &epoch_wr); srand48((long int)time(NULL)); ck_ht_allocator_set(&my_allocator); - if (ck_ht_init(&ht, CK_HT_MODE_DIRECT, NULL, 8, lrand48()) == false) { + if (ck_ht_init(&ht, CK_HT_MODE_DIRECT, hash_function, 8, lrand48()) == false) { perror("ck_ht_init"); exit(EXIT_FAILURE); }