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_normalizer.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_normalizer.zig')
| -rw-r--r-- | bench/src/ziglyph_normalizer.zig | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/bench/src/ziglyph_normalizer.zig b/bench/src/ziglyph_normalizer.zig index fea162c..fa077f4 100644 --- a/bench/src/ziglyph_normalizer.zig +++ b/bench/src/ziglyph_normalizer.zig | |||
| @@ -3,14 +3,14 @@ const std = @import("std"); | |||
| 3 | const Normalizer = @import("ziglyph").Normalizer; | 3 | const Normalizer = @import("ziglyph").Normalizer; |
| 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, |
| @@ -28,7 +28,7 @@ pub fn main() !void { | |||
| 28 | const nfkc = try normalizer.nfkc(allocator, line); | 28 | const nfkc = try normalizer.nfkc(allocator, line); |
| 29 | result += nfkc.slice.len; | 29 | result += nfkc.slice.len; |
| 30 | } | 30 | } |
| 31 | std.debug.print("Ziglyph Normalizer.nfkc: result: {}, took: {}\n", .{ result, timer.lap() / std.time.ns_per_ms }); | 31 | std.debug.print("Ziglyph Normalizer.nfkc: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap() / std.time.ns_per_ms) }); |
| 32 | 32 | ||
| 33 | result = 0; | 33 | result = 0; |
| 34 | iter.reset(); | 34 | iter.reset(); |
| @@ -38,7 +38,7 @@ pub fn main() !void { | |||
| 38 | const nfc = try normalizer.nfc(allocator, line); | 38 | const nfc = try normalizer.nfc(allocator, line); |
| 39 | result += nfc.slice.len; | 39 | result += nfc.slice.len; |
| 40 | } | 40 | } |
| 41 | std.debug.print("Ziglyph Normalizer.nfc: result: {}, took: {}\n", .{ result, timer.lap() / std.time.ns_per_ms }); | 41 | std.debug.print("Ziglyph Normalizer.nfc: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap() / std.time.ns_per_ms) }); |
| 42 | 42 | ||
| 43 | result = 0; | 43 | result = 0; |
| 44 | iter.reset(); | 44 | iter.reset(); |
| @@ -48,7 +48,7 @@ pub fn main() !void { | |||
| 48 | const nfkd = try normalizer.nfkd(allocator, line); | 48 | const nfkd = try normalizer.nfkd(allocator, line); |
| 49 | result += nfkd.slice.len; | 49 | result += nfkd.slice.len; |
| 50 | } | 50 | } |
| 51 | std.debug.print("Ziglyph Normalizer.nfkd: result: {}, took: {}\n", .{ result, timer.lap() / std.time.ns_per_ms }); | 51 | std.debug.print("Ziglyph Normalizer.nfkd: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap() / std.time.ns_per_ms) }); |
| 52 | 52 | ||
| 53 | result = 0; | 53 | result = 0; |
| 54 | iter.reset(); | 54 | iter.reset(); |
| @@ -58,7 +58,7 @@ pub fn main() !void { | |||
| 58 | const nfd = try normalizer.nfd(allocator, line); | 58 | const nfd = try normalizer.nfd(allocator, line); |
| 59 | result += nfd.slice.len; | 59 | result += nfd.slice.len; |
| 60 | } | 60 | } |
| 61 | std.debug.print("Ziglyph Normalizer.nfd: result: {}, took: {}\n", .{ result, timer.lap() / std.time.ns_per_ms }); | 61 | std.debug.print("Ziglyph Normalizer.nfd: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap() / std.time.ns_per_ms) }); |
| 62 | 62 | ||
| 63 | result = 0; | 63 | result = 0; |
| 64 | iter.reset(); | 64 | iter.reset(); |
| @@ -71,5 +71,5 @@ pub fn main() !void { | |||
| 71 | @memcpy(buf[0..line.len], line); | 71 | @memcpy(buf[0..line.len], line); |
| 72 | prev_line = buf[0..line.len]; | 72 | prev_line = buf[0..line.len]; |
| 73 | } | 73 | } |
| 74 | std.debug.print("Ziglyph Normalizer.eql: result: {}, took: {}\n", .{ result, timer.lap() / std.time.ns_per_ms }); | 74 | std.debug.print("Ziglyph Normalizer.eql: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap() / std.time.ns_per_ms) }); |
| 75 | } | 75 | } |