| ... | ... | @@ -317,12 +317,13 @@ const pwhashes = [_]CryptoPwhash{ |
| 317 | 317 | }; |
| 318 | 318 | |
| 319 | 319 | fn benchmarkPwhash( |
| 320 | allocator: mem.Allocator, |
| 320 | 321 | comptime ty: anytype, |
| 321 | 322 | comptime params: *const anyopaque, |
| 322 | 323 | comptime count: comptime_int, |
| 323 | 324 | ) !f64 { |
| 324 | 325 | const password = "testpass" ** 2; |
| 325 | | const opts = .{ .allocator = std.testing.allocator, .params = @ptrCast(*const ty.Params, params).*, .encoding = .phc }; |
| 326 | const opts = .{ .allocator = allocator, .params = @ptrCast(*const ty.Params, params).*, .encoding = .phc }; |
| 326 | 327 | var buf: [256]u8 = undefined; |
| 327 | 328 | |
| 328 | 329 | var timer = try Timer.start(); |
| ... | ... | @@ -361,9 +362,10 @@ fn mode(comptime x: comptime_int) comptime_int { |
| 361 | 362 | pub fn main() !void { |
| 362 | 363 | const stdout = std.io.getStdOut().writer(); |
| 363 | 364 | |
| 364 | | var buffer: [1024]u8 = undefined; |
| 365 | | var fixed = std.heap.FixedBufferAllocator.init(buffer[0..]); |
| 366 | | const args = try std.process.argsAlloc(fixed.allocator()); |
| 365 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| 366 | defer arena.deinit(); |
| 367 | const arena_allocator = arena.allocator(); |
| 368 | const args = try std.process.argsAlloc(arena_allocator); |
| 367 | 369 | |
| 368 | 370 | var filter: ?[]u8 = ""; |
| 369 | 371 | |
| ... | ... | @@ -463,7 +465,7 @@ pub fn main() !void { |
| 463 | 465 | |
| 464 | 466 | inline for (pwhashes) |H| { |
| 465 | 467 | if (filter == null or std.mem.indexOf(u8, H.name, filter.?) != null) { |
| 466 | | const throughput = try benchmarkPwhash(H.ty, H.params, mode(64)); |
| 468 | const throughput = try benchmarkPwhash(arena_allocator, H.ty, H.params, mode(64)); |
| 467 | 469 | try stdout.print("{s:>17}: {d:10.3} s/ops\n", .{ H.name, throughput }); |
| 468 | 470 | } |
| 469 | 471 | } |