diff options
Diffstat (limited to 'bench/src/zg_caseless.zig')
| -rw-r--r-- | bench/src/zg_caseless.zig | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/bench/src/zg_caseless.zig b/bench/src/zg_caseless.zig index fa350e9..5d8d591 100644 --- a/bench/src/zg_caseless.zig +++ b/bench/src/zg_caseless.zig | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | const CaseFold = @import("CaseFold"); | 3 | const CaseFolding = @import("CaseFolding"); |
| 4 | const Normalize = @import("Normalize"); | ||
| 5 | 4 | ||
| 6 | pub fn main() !void { | 5 | pub fn main() !void { |
| 7 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); | 6 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| @@ -19,11 +18,7 @@ pub fn main() !void { | |||
| 19 | ); | 18 | ); |
| 20 | defer allocator.free(input); | 19 | defer allocator.free(input); |
| 21 | 20 | ||
| 22 | const fold_data = try CaseFold.FoldData.init(allocator); | 21 | const case_fold = try CaseFolding.init(allocator); |
| 23 | var case_fold = CaseFold{ .fold_data = &fold_data }; | ||
| 24 | var norm_data: Normalize.NormData = undefined; | ||
| 25 | try Normalize.NormData.init(&norm_data, allocator); | ||
| 26 | var normalize = Normalize{ .norm_data = &norm_data }; | ||
| 27 | 22 | ||
| 28 | var iter = std.mem.splitScalar(u8, input, '\n'); | 23 | var iter = std.mem.splitScalar(u8, input, '\n'); |
| 29 | var result: usize = 0; | 24 | var result: usize = 0; |
| @@ -34,14 +29,13 @@ pub fn main() !void { | |||
| 34 | while (iter.next()) |line| { | 29 | while (iter.next()) |line| { |
| 35 | if (try case_fold.compatCaselessMatch( | 30 | if (try case_fold.compatCaselessMatch( |
| 36 | allocator, | 31 | allocator, |
| 37 | &normalize, | ||
| 38 | prev_line, | 32 | prev_line, |
| 39 | line, | 33 | line, |
| 40 | )) result += 1; | 34 | )) result += 1; |
| 41 | @memcpy(buf[0..line.len], line); | 35 | @memcpy(buf[0..line.len], line); |
| 42 | prev_line = buf[0..line.len]; | 36 | prev_line = buf[0..line.len]; |
| 43 | } | 37 | } |
| 44 | std.debug.print("zg CaseFold.compatCaselessMatch: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap()) }); | 38 | std.debug.print("zg CaseFolding.compatCaselessMatch: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap()) }); |
| 45 | 39 | ||
| 46 | result = 0; | 40 | result = 0; |
| 47 | iter.reset(); | 41 | iter.reset(); |
| @@ -50,12 +44,11 @@ pub fn main() !void { | |||
| 50 | while (iter.next()) |line| { | 44 | while (iter.next()) |line| { |
| 51 | if (try case_fold.canonCaselessMatch( | 45 | if (try case_fold.canonCaselessMatch( |
| 52 | allocator, | 46 | allocator, |
| 53 | &normalize, | ||
| 54 | prev_line, | 47 | prev_line, |
| 55 | line, | 48 | line, |
| 56 | )) result += 1; | 49 | )) result += 1; |
| 57 | @memcpy(buf[0..line.len], line); | 50 | @memcpy(buf[0..line.len], line); |
| 58 | prev_line = buf[0..line.len]; | 51 | prev_line = buf[0..line.len]; |
| 59 | } | 52 | } |
| 60 | std.debug.print("zg CaseFold.canonCaselessMatch: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap()) }); | 53 | std.debug.print("zg CaseFolding.canonCaselessMatch: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap()) }); |
| 61 | } | 54 | } |