summaryrefslogtreecommitdiff
path: root/bench/src/ziglyph_normalizer.zig
diff options
context:
space:
mode:
Diffstat (limited to 'bench/src/ziglyph_normalizer.zig')
-rw-r--r--bench/src/ziglyph_normalizer.zig18
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");
3const Normalizer = @import("ziglyph").Normalizer; 3const Normalizer = @import("ziglyph").Normalizer;
4 4
5pub fn main() !void { 5pub 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}