diff options
| author | 2025-05-16 13:13:01 -0400 | |
|---|---|---|
| committer | 2025-05-16 13:13:01 -0400 | |
| commit | 036923515ec05b07c381448402fc256d9c564c10 (patch) | |
| tree | c3c170fb68f7504be8522acf8172977931541013 /bench/src/zg_normalize.zig | |
| parent | Merge stranded README changes from v0.14 release (diff) | |
| download | zg-036923515ec05b07c381448402fc256d9c564c10.tar.gz zg-036923515ec05b07c381448402fc256d9c564c10.tar.xz zg-036923515ec05b07c381448402fc256d9c564c10.zip | |
Remove benchmarks, ziglyph references
`ziglyph` is no longer maintained and basically abandoned, there's no
need to keep the comparison between them active going forward.
Diffstat (limited to 'bench/src/zg_normalize.zig')
| -rw-r--r-- | bench/src/zg_normalize.zig | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/bench/src/zg_normalize.zig b/bench/src/zg_normalize.zig deleted file mode 100644 index 1e2cfab..0000000 --- a/bench/src/zg_normalize.zig +++ /dev/null | |||
| @@ -1,77 +0,0 @@ | |||
| 1 | const std = @import("std"); | ||
| 2 | |||
| 3 | const Normalize = @import("Normalize"); | ||
| 4 | |||
| 5 | pub fn main() !void { | ||
| 6 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); | ||
| 7 | defer arena.deinit(); | ||
| 8 | const allocator = arena.allocator(); | ||
| 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( | ||
| 15 | allocator, | ||
| 16 | in_path, | ||
| 17 | std.math.maxInt(u32), | ||
| 18 | ); | ||
| 19 | defer allocator.free(input); | ||
| 20 | |||
| 21 | var norm_data: Normalize.NormData = undefined; | ||
| 22 | try Normalize.NormData.init(&norm_data, allocator); | ||
| 23 | const normalize = Normalize{ .norm_data = &norm_data }; | ||
| 24 | |||
| 25 | var iter = std.mem.splitScalar(u8, input, '\n'); | ||
| 26 | var result: usize = 0; | ||
| 27 | var timer = try std.time.Timer.start(); | ||
| 28 | |||
| 29 | while (iter.next()) |line| { | ||
| 30 | const nfkc = try normalize.nfkc(allocator, line); | ||
| 31 | result += nfkc.slice.len; | ||
| 32 | } | ||
| 33 | std.debug.print("zg Normalize.nfkc: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap()) }); | ||
| 34 | |||
| 35 | result = 0; | ||
| 36 | iter.reset(); | ||
| 37 | timer.reset(); | ||
| 38 | |||
| 39 | while (iter.next()) |line| { | ||
| 40 | const nfc = try normalize.nfc(allocator, line); | ||
| 41 | result += nfc.slice.len; | ||
| 42 | } | ||
| 43 | std.debug.print("zg Normalize.nfc: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap()) }); | ||
| 44 | |||
| 45 | result = 0; | ||
| 46 | iter.reset(); | ||
| 47 | timer.reset(); | ||
| 48 | |||
| 49 | while (iter.next()) |line| { | ||
| 50 | const nfkd = try normalize.nfkd(allocator, line); | ||
| 51 | result += nfkd.slice.len; | ||
| 52 | } | ||
| 53 | std.debug.print("zg Normalize.nfkd: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap()) }); | ||
| 54 | |||
| 55 | result = 0; | ||
| 56 | iter.reset(); | ||
| 57 | timer.reset(); | ||
| 58 | |||
| 59 | while (iter.next()) |line| { | ||
| 60 | const nfd = try normalize.nfd(allocator, line); | ||
| 61 | result += nfd.slice.len; | ||
| 62 | } | ||
| 63 | std.debug.print("zg Normalize.nfd: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap()) }); | ||
| 64 | |||
| 65 | result = 0; | ||
| 66 | iter.reset(); | ||
| 67 | var buf: [256]u8 = [_]u8{'z'} ** 256; | ||
| 68 | var prev_line: []const u8 = buf[0..1]; | ||
| 69 | timer.reset(); | ||
| 70 | |||
| 71 | while (iter.next()) |line| { | ||
| 72 | if (try normalize.eql(allocator, prev_line, line)) result += 1; | ||
| 73 | @memcpy(buf[0..line.len], line); | ||
| 74 | prev_line = buf[0..line.len]; | ||
| 75 | } | ||
| 76 | std.debug.print("Zg Normalize.eql: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap()) }); | ||
| 77 | } | ||