Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit 26c2231

Browse files
committed
Modify test
1 parent 3086c01 commit 26c2231

File tree

1 file changed

+45
-3
lines changed

1 file changed

+45
-3
lines changed

test/codegen/oa_hash_table_test.cpp

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
#include "libcuckoo/cuckoohash_map.hh"
1919

2020
#include "codegen/util/oa_hash_table.h"
21+
#include "codegen/util/hash_table.h"
2122
#include "common/timer.h"
23+
#include "type/ephemeral_pool.h"
2224

2325
namespace peloton {
2426
namespace test {
@@ -47,10 +49,10 @@ class OAHashTableTest : public PelotonTest {
4749

4850
OAHashTableTest() : ht_(sizeof(Key), sizeof(Value)) {}
4951

50-
static uint32_t Hash(const Key &k) {
52+
static uint64_t Hash(const Key &k) {
5153
static constexpr uint32_t seed = 12345;
52-
auto h1 = MurmurHash3_x86_32(&k.k1, sizeof(uint32_t), seed);
53-
auto h2 = MurmurHash3_x86_32(&k.k2, sizeof(uint32_t), seed);
54+
uint64_t h1 = MurmurHash3_x86_32(&k.k1, sizeof(uint32_t), seed);
55+
uint64_t h2 = MurmurHash3_x86_32(&k.k2, sizeof(uint32_t), seed);
5456
return h1 ^ (h2 + 0x9e3779b9 + (h1 << 6) + (h1 >> 2));
5557
}
5658

@@ -147,6 +149,7 @@ TEST_F(OAHashTableTest, MicroBenchmark) {
147149
}
148150

149151
double avg_oaht_insert = 0.0, avg_oaht_probe = 0.0;
152+
double avg_lazyht_insert = 0.0, avg_lazyht_probe = 0.0;
150153
double avg_map_insert = 0.0, avg_map_probe = 0.0;
151154
double avg_cuckoo_insert = 0.0, avg_cuckoo_probe = 0.0;
152155

@@ -186,6 +189,42 @@ TEST_F(OAHashTableTest, MicroBenchmark) {
186189
}
187190
}
188191

192+
// First, bench ours ...
193+
{
194+
for (uint32_t b = 0; b < num_runs; b++) {
195+
::peloton::type::EphemeralPool pool;
196+
codegen::util::HashTable ht(pool, sizeof(Key), sizeof(Value));
197+
198+
Timer<std::ratio<1, 1000>> timer;
199+
timer.Start();
200+
201+
// Start Insert
202+
for (uint32_t i = 0; i < num_keys; i++) {
203+
ht.TypedInsertLazy(Hash(keys[i]), keys[i], v);
204+
}
205+
ht.BuildLazy();
206+
// End Insert
207+
208+
timer.Stop();
209+
avg_lazyht_insert += timer.GetDuration();
210+
211+
timer.Reset();
212+
timer.Start();
213+
214+
// Start Probe
215+
std::vector<Key> shuffled = keys;
216+
std::random_shuffle(shuffled.begin(), shuffled.end());
217+
for (uint32_t i = 0; i < num_keys; i++) {
218+
Value probe_val;
219+
EXPECT_TRUE(ht.TypedProbe(Hash(shuffled[i]), shuffled[i], probe_val));
220+
}
221+
// End Probe
222+
223+
timer.Stop();
224+
avg_lazyht_probe += timer.GetDuration();
225+
}
226+
}
227+
189228
// Next, unordered_map ...
190229
{
191230
struct Hasher {
@@ -262,6 +301,9 @@ TEST_F(OAHashTableTest, MicroBenchmark) {
262301
LOG_INFO("OA_HT insert: %.2lf, probe: %.2lf",
263302
avg_oaht_insert / (double)num_runs,
264303
avg_oaht_probe / (double)num_runs);
304+
LOG_INFO("Lazy HT insert: %.2lf, probe: %.2lf",
305+
avg_lazyht_insert / (double)num_runs,
306+
avg_lazyht_probe / (double)num_runs);
265307
LOG_INFO("std::unordered_map insert: %.2lf, probe: %.2lf",
266308
avg_map_insert / (double)num_runs, avg_map_probe / (double)num_runs);
267309
LOG_INFO("Cuckoo insert: %.2lf, probe: %.2lf",

0 commit comments

Comments
 (0)