From b305389dc741dfe3fb5300d4383ade4cddb2ba3e Mon Sep 17 00:00:00 2001 From: Ryan Liptak Date: Thu, 27 Jun 2024 01:56:54 -0700 Subject: bench: Fix for Windows and use fmtDuration --- bench/src/zg_normalize.zig | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'bench/src/zg_normalize.zig') diff --git a/bench/src/zg_normalize.zig b/bench/src/zg_normalize.zig index 87d07da..fb0d4ee 100644 --- a/bench/src/zg_normalize.zig +++ b/bench/src/zg_normalize.zig @@ -3,14 +3,14 @@ const std = @import("std"); const Normalize = @import("Normalize"); pub fn main() !void { - var args_iter = std.process.args(); - _ = args_iter.skip(); - const in_path = args_iter.next() orelse return error.MissingArg; - var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer arena.deinit(); const allocator = arena.allocator(); + var args_iter = try std.process.argsWithAllocator(allocator); + _ = args_iter.skip(); + const in_path = args_iter.next() orelse return error.MissingArg; + const input = try std.fs.cwd().readFileAlloc( allocator, in_path, @@ -30,7 +30,7 @@ pub fn main() !void { const nfkc = try normalize.nfkc(allocator, line); result += nfkc.slice.len; } - std.debug.print("zg Normalize.nfkc: result: {}, took: {}\n", .{ result, timer.lap() / std.time.ns_per_ms }); + std.debug.print("zg Normalize.nfkc: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap() / std.time.ns_per_ms) }); result = 0; iter.reset(); @@ -40,7 +40,7 @@ pub fn main() !void { const nfc = try normalize.nfc(allocator, line); result += nfc.slice.len; } - std.debug.print("zg Normalize.nfc: result: {}, took: {}\n", .{ result, timer.lap() / std.time.ns_per_ms }); + std.debug.print("zg Normalize.nfc: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap() / std.time.ns_per_ms) }); result = 0; iter.reset(); @@ -50,7 +50,7 @@ pub fn main() !void { const nfkd = try normalize.nfkd(allocator, line); result += nfkd.slice.len; } - std.debug.print("zg Normalize.nfkd: result: {}, took: {}\n", .{ result, timer.lap() / std.time.ns_per_ms }); + std.debug.print("zg Normalize.nfkd: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap() / std.time.ns_per_ms) }); result = 0; iter.reset(); @@ -60,7 +60,7 @@ pub fn main() !void { const nfd = try normalize.nfd(allocator, line); result += nfd.slice.len; } - std.debug.print("zg Normalize.nfd: result: {}, took: {}\n", .{ result, timer.lap() / std.time.ns_per_ms }); + std.debug.print("zg Normalize.nfd: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap() / std.time.ns_per_ms) }); result = 0; iter.reset(); @@ -73,5 +73,5 @@ pub fn main() !void { @memcpy(buf[0..line.len], line); prev_line = buf[0..line.len]; } - std.debug.print("Zg Normalize.eql: result: {}, took: {}\n", .{ result, timer.lap() / std.time.ns_per_ms }); + std.debug.print("Zg Normalize.eql: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap() / std.time.ns_per_ms) }); } -- cgit v1.2.3