also looking at this
Port to latest zig-master
#2
53 files
+1149
-1017
| @@ -27,7 +27,7 @@ const Benchmark = struct { | ||
| 27 | 27 | } |
| 28 | 28 | }; |
| 29 | 29 | |
| 30 | pub fn main() !void { | |
| 30 | pub fn main(init: std.process.Init) !void { | |
| 31 | 31 | var gpa = std.heap.GeneralPurposeAllocator(.{}){}; |
| 32 | 32 | defer _ = gpa.deinit(); |
| 33 | 33 | const allocator = gpa.allocator(); |
| @@ -36,7 +36,7 @@ pub fn main() !void { | ||
| 36 | 36 | |
| 37 | 37 | // Benchmark 1: Simple literal matching |
| 38 | 38 | { |
| 39 | var regex = try Regex.compile(allocator, "hello"); | |
| 39 | var regex = try Regex.compile(allocator, init.io, "hello"); | |
| 40 | 40 | defer regex.deinit(); |
| 41 | 41 | const input = "hello world"; |
| 42 | 42 | |
| @@ -50,7 +50,7 @@ pub fn main() !void { | ||
| 50 | 50 | |
| 51 | 51 | // Benchmark 2: Quantifier matching |
| 52 | 52 | { |
| 53 | var regex = try Regex.compile(allocator, "a+b*c?"); | |
| 53 | var regex = try Regex.compile(allocator, init.io, "a+b*c?"); | |
| 54 | 54 | defer regex.deinit(); |
| 55 | 55 | const input = "aaabbbbc"; |
| 56 | 56 | |
| @@ -64,7 +64,7 @@ pub fn main() !void { | ||
| 64 | 64 | |
| 65 | 65 | // Benchmark 3: Alternation |
| 66 | 66 | { |
| 67 | var regex = try Regex.compile(allocator, "cat|dog|bird"); | |
| 67 | var regex = try Regex.compile(allocator, init.io, "cat|dog|bird"); | |
| 68 | 68 | defer regex.deinit(); |
| 69 | 69 | const input = "dog"; |
| 70 | 70 | |
| @@ -78,7 +78,7 @@ pub fn main() !void { | ||
| 78 | 78 | |
| 79 | 79 | // Benchmark 4: Character class |
| 80 | 80 | { |
| 81 | var regex = try Regex.compile(allocator, "[a-z]+"); | |
| 81 | var regex = try Regex.compile(allocator, init.io, "[a-z]+"); | |
| 82 | 82 | defer regex.deinit(); |
| 83 | 83 | const input = "abcdefghijklmnop"; |
| 84 | 84 | |
| @@ -92,7 +92,7 @@ pub fn main() !void { | ||
| 92 | 92 | |
| 93 | 93 | // Benchmark 5: Digit matching |
| 94 | 94 | { |
| 95 | var regex = try Regex.compile(allocator, "\\d{3}-\\d{4}"); | |
| 95 | var regex = try Regex.compile(allocator, init.io, "\\d{3}-\\d{4}"); | |
| 96 | 96 | defer regex.deinit(); |
| 97 | 97 | const input = "555-1234"; |
| 98 | 98 | |
| @@ -106,7 +106,7 @@ pub fn main() !void { | ||
| 106 | 106 | |
| 107 | 107 | // Benchmark 6: Email-like pattern |
| 108 | 108 | { |
| 109 | var regex = try Regex.compile(allocator, "\\w+@\\w+\\.\\w+"); | |
| 109 | var regex = try Regex.compile(allocator, init.io, "\\w+@\\w+\\.\\w+"); | |
| 110 | 110 | defer regex.deinit(); |
| 111 | 111 | const input = "user@example.com"; |
| 112 | 112 | |
| @@ -120,7 +120,7 @@ pub fn main() !void { | ||
| 120 | 120 | |
| 121 | 121 | // Benchmark 7: Find operation |
| 122 | 122 | { |
| 123 | var regex = try Regex.compile(allocator, "\\d+"); | |
| 123 | var regex = try Regex.compile(allocator, init.io, "\\d+"); | |
| 124 | 124 | defer regex.deinit(); |
| 125 | 125 | const input = "The price is $123 and tax is $45"; |
| 126 | 126 | |
| @@ -137,7 +137,7 @@ pub fn main() !void { | ||
| 137 | 137 | |
| 138 | 138 | // Benchmark 8: Replace operation |
| 139 | 139 | { |
| 140 | var regex = try Regex.compile(allocator, "\\d+"); | |
| 140 | var regex = try Regex.compile(allocator, init.io, "\\d+"); | |
| 141 | 141 | defer regex.deinit(); |
| 142 | 142 | const input = "Call 555-1234 or 555-5678"; |
| 143 | 143 | |
| @@ -166,7 +166,7 @@ pub fn main() !void { | ||
| 166 | 166 | |
| 167 | 167 | // Benchmark 10: Complex pattern |
| 168 | 168 | { |
| 169 | var regex = try Regex.compile(allocator, "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"); | |
| 169 | var regex = try Regex.compile(allocator, init.io, "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"); | |
| 170 | 170 | defer regex.deinit(); |
| 171 | 171 | const input = "test.user+tag@example.co.uk"; |
| 172 | 172 | |