summaryrefslogtreecommitdiff
path: root/bench/src/zg_normalize.zig
diff options
context:
space:
mode:
Diffstat (limited to 'bench/src/zg_normalize.zig')
-rw-r--r--bench/src/zg_normalize.zig18
1 files changed, 9 insertions, 9 deletions
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");
3const Normalize = @import("Normalize"); 3const Normalize = @import("Normalize");
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,
@@ -30,7 +30,7 @@ pub fn main() !void {
30 const nfkc = try normalize.nfkc(allocator, line); 30 const nfkc = try normalize.nfkc(allocator, line);
31 result += nfkc.slice.len; 31 result += nfkc.slice.len;
32 } 32 }
33 std.debug.print("zg Normalize.nfkc: result: {}, took: {}\n", .{ result, timer.lap() / std.time.ns_per_ms }); 33 std.debug.print("zg Normalize.nfkc: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap() / std.time.ns_per_ms) });
34 34
35 result = 0; 35 result = 0;
36 iter.reset(); 36 iter.reset();
@@ -40,7 +40,7 @@ pub fn main() !void {
40 const nfc = try normalize.nfc(allocator, line); 40 const nfc = try normalize.nfc(allocator, line);
41 result += nfc.slice.len; 41 result += nfc.slice.len;
42 } 42 }
43 std.debug.print("zg Normalize.nfc: result: {}, took: {}\n", .{ result, timer.lap() / std.time.ns_per_ms }); 43 std.debug.print("zg Normalize.nfc: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap() / std.time.ns_per_ms) });
44 44
45 result = 0; 45 result = 0;
46 iter.reset(); 46 iter.reset();
@@ -50,7 +50,7 @@ pub fn main() !void {
50 const nfkd = try normalize.nfkd(allocator, line); 50 const nfkd = try normalize.nfkd(allocator, line);
51 result += nfkd.slice.len; 51 result += nfkd.slice.len;
52 } 52 }
53 std.debug.print("zg Normalize.nfkd: result: {}, took: {}\n", .{ result, timer.lap() / std.time.ns_per_ms }); 53 std.debug.print("zg Normalize.nfkd: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap() / std.time.ns_per_ms) });
54 54
55 result = 0; 55 result = 0;
56 iter.reset(); 56 iter.reset();
@@ -60,7 +60,7 @@ pub fn main() !void {
60 const nfd = try normalize.nfd(allocator, line); 60 const nfd = try normalize.nfd(allocator, line);
61 result += nfd.slice.len; 61 result += nfd.slice.len;
62 } 62 }
63 std.debug.print("zg Normalize.nfd: result: {}, took: {}\n", .{ result, timer.lap() / std.time.ns_per_ms }); 63 std.debug.print("zg Normalize.nfd: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap() / std.time.ns_per_ms) });
64 64
65 result = 0; 65 result = 0;
66 iter.reset(); 66 iter.reset();
@@ -73,5 +73,5 @@ pub fn main() !void {
73 @memcpy(buf[0..line.len], line); 73 @memcpy(buf[0..line.len], line);
74 prev_line = buf[0..line.len]; 74 prev_line = buf[0..line.len];
75 } 75 }
76 std.debug.print("Zg Normalize.eql: result: {}, took: {}\n", .{ result, timer.lap() / std.time.ns_per_ms }); 76 std.debug.print("Zg Normalize.eql: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap() / std.time.ns_per_ms) });
77} 77}