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/ziglyph_case.zig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'bench/src/ziglyph_case.zig') diff --git a/bench/src/ziglyph_case.zig b/bench/src/ziglyph_case.zig index c6ef6ec..2b49e5a 100644 --- a/bench/src/ziglyph_case.zig +++ b/bench/src/ziglyph_case.zig @@ -3,14 +3,14 @@ const std = @import("std"); const ziglyph = @import("ziglyph"); 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, @@ -27,7 +27,7 @@ pub fn main() !void { const lower = try ziglyph.toLowerStr(allocator, line); result += upper.len + lower.len; } - std.debug.print("Ziglyph toUpperStr/toLowerStr: result: {}, took: {}\n", .{ result, timer.lap() / std.time.ns_per_ms }); + std.debug.print("Ziglyph toUpperStr/toLowerStr: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap() / std.time.ns_per_ms) }); result = 0; iter.reset(); @@ -37,5 +37,5 @@ pub fn main() !void { if (ziglyph.isUpperStr(line)) result += 1; if (ziglyph.isLowerStr(line)) result += 2; } - std.debug.print("Ziglyph isUpperStr/isLowerStr: result: {}, took: {}\n", .{ result, timer.lap() / std.time.ns_per_ms }); + std.debug.print("Ziglyph isUpperStr/isLowerStr: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap() / std.time.ns_per_ms) }); } -- cgit v1.2.3