forked from tigerbeetle/tigerbeetle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark.zig
30 lines (25 loc) · 897 Bytes
/
benchmark.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const std = @import("std");
pub fn main() !void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const allocator = arena.allocator();
const runs: usize = 5;
const insertions: usize = 1000000;
const transfer: [128]u8 = [_]u8{0} ** 128;
var transfers = std.AutoHashMap(u128, @TypeOf(transfer)).init(allocator);
try transfers.ensureTotalCapacity(insertions * runs);
var id: u128 = 0;
var run: usize = 0;
while (run < runs) : (run += 1) {
var start = std.time.milliTimestamp();
var count: usize = 0;
while (count < insertions) : (count += 1) {
transfers.putAssumeCapacity(id, transfer);
id += 1;
}
std.debug.print("{} hash table insertions in {}ms\n", .{
insertions,
std.time.milliTimestamp() - start,
});
}
}