From 052dd57cdd9573d1703a43662a49988549f7c4e3 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Sat, 14 Sep 2024 18:17:35 -0500 Subject: [PATCH] fix(bench): use c allocator --- build.zig | 1 + src/bench.zig | 7 ++----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/build.zig b/build.zig index 392714a..dbfc1de 100644 --- a/build.zig +++ b/build.zig @@ -37,6 +37,7 @@ pub fn build(b: *std.Build) void { .root_source_file = b.path("src/bench.zig"), .target = target, .optimize = .ReleaseFast, + .link_libc = true, }); bench.root_module.addImport("hamt", mod); diff --git a/src/bench.zig b/src/bench.zig index 38dd2b4..3e089ea 100644 --- a/src/bench.zig +++ b/src/bench.zig @@ -17,16 +17,13 @@ const StringArrayHashMap = std.array_hash_map.StringArrayHashMap(void); const StringHashMap = std.hash_map.StringHashMap(void); pub fn main() !void { - var gpa = std.heap.GeneralPurposeAllocator(.{}){}; - defer std.debug.assert(gpa.deinit() == .ok); - - const allocator = gpa.allocator(); + const allocator = std.heap.c_allocator; const elem_count = 1000; const keys = try allocator.alloc([32]u8, elem_count); defer allocator.free(keys); - var rand = std.rand.DefaultPrng.init(1337); + var rand = std.rand.DefaultPrng.init(0); for (keys) |*key| rand.fill(key); var trie = try HashArrayMappedTrie([]const u8, void, StringContext).init(allocator);