diff options
| author | 2024-06-27 01:56:54 -0700 | |
|---|---|---|
| committer | 2024-06-27 01:56:54 -0700 | |
| commit | b305389dc741dfe3fb5300d4383ade4cddb2ba3e (patch) | |
| tree | bffbeb1c061833a7f043794f4c7470615433ed4c /bench/src/ziglyph_case.zig | |
| parent | Implements new case fold data encoding by @sqeek502 #8 (diff) | |
| download | zg-b305389dc741dfe3fb5300d4383ade4cddb2ba3e.tar.gz zg-b305389dc741dfe3fb5300d4383ade4cddb2ba3e.tar.xz zg-b305389dc741dfe3fb5300d4383ade4cddb2ba3e.zip | |
bench: Fix for Windows and use fmtDuration
Diffstat (limited to 'bench/src/ziglyph_case.zig')
| -rw-r--r-- | bench/src/ziglyph_case.zig | 12 |
1 files changed, 6 insertions, 6 deletions
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"); | |||
| 3 | const ziglyph = @import("ziglyph"); | 3 | const ziglyph = @import("ziglyph"); |
| 4 | 4 | ||
| 5 | pub fn main() !void { | 5 | pub fn main() !void { |
| 6 | var args_iter = std.process.args(); | ||
| 7 | _ = args_iter.skip(); | ||
| 8 | const in_path = args_iter.next() orelse return error.MissingArg; | ||
| 9 | |||
| 10 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); | 6 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| 11 | defer arena.deinit(); | 7 | defer arena.deinit(); |
| 12 | const allocator = arena.allocator(); | 8 | const allocator = arena.allocator(); |
| 13 | 9 | ||
| 10 | var args_iter = try std.process.argsWithAllocator(allocator); | ||
| 11 | _ = args_iter.skip(); | ||
| 12 | const in_path = args_iter.next() orelse return error.MissingArg; | ||
| 13 | |||
| 14 | const input = try std.fs.cwd().readFileAlloc( | 14 | const input = try std.fs.cwd().readFileAlloc( |
| 15 | allocator, | 15 | allocator, |
| 16 | in_path, | 16 | in_path, |
| @@ -27,7 +27,7 @@ pub fn main() !void { | |||
| 27 | const lower = try ziglyph.toLowerStr(allocator, line); | 27 | const lower = try ziglyph.toLowerStr(allocator, line); |
| 28 | result += upper.len + lower.len; | 28 | result += upper.len + lower.len; |
| 29 | } | 29 | } |
| 30 | std.debug.print("Ziglyph toUpperStr/toLowerStr: result: {}, took: {}\n", .{ result, timer.lap() / std.time.ns_per_ms }); | 30 | std.debug.print("Ziglyph toUpperStr/toLowerStr: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap() / std.time.ns_per_ms) }); |
| 31 | 31 | ||
| 32 | result = 0; | 32 | result = 0; |
| 33 | iter.reset(); | 33 | iter.reset(); |
| @@ -37,5 +37,5 @@ pub fn main() !void { | |||
| 37 | if (ziglyph.isUpperStr(line)) result += 1; | 37 | if (ziglyph.isUpperStr(line)) result += 1; |
| 38 | if (ziglyph.isLowerStr(line)) result += 2; | 38 | if (ziglyph.isLowerStr(line)) result += 2; |
| 39 | } | 39 | } |
| 40 | std.debug.print("Ziglyph isUpperStr/isLowerStr: result: {}, took: {}\n", .{ result, timer.lap() / std.time.ns_per_ms }); | 40 | std.debug.print("Ziglyph isUpperStr/isLowerStr: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap() / std.time.ns_per_ms) }); |
| 41 | } | 41 | } |