summaryrefslogtreecommitdiff
path: root/bench/src/ziglyph_codepoint.zig
diff options
context:
space:
mode:
authorGravatar Jose Colon Rodriguez2024-03-31 11:26:14 -0400
committerGravatar Jose Colon Rodriguez2024-03-31 11:26:14 -0400
commitf1cfab7059e922d45ebbe19c58acef8fa80dc85e (patch)
treef8067e499095514185eca7e04077a6d64a1bd01b /bench/src/ziglyph_codepoint.zig
parentAdded Ghostty ref in README (diff)
downloadzg-f1cfab7059e922d45ebbe19c58acef8fa80dc85e.tar.gz
zg-f1cfab7059e922d45ebbe19c58acef8fa80dc85e.tar.xz
zg-f1cfab7059e922d45ebbe19c58acef8fa80dc85e.zip
Added benchmarks; Unicode version; Removed Ziglyph dep
Diffstat (limited to '')
-rw-r--r--bench/src/ziglyph_codepoint.zig27
1 files changed, 27 insertions, 0 deletions
diff --git a/bench/src/ziglyph_codepoint.zig b/bench/src/ziglyph_codepoint.zig
new file mode 100644
index 0000000..4c8fc18
--- /dev/null
+++ b/bench/src/ziglyph_codepoint.zig
@@ -0,0 +1,27 @@
1const std = @import("std");
2
3const CodePointIterator = @import("ziglyph").CodePointIterator;
4
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);
11 defer arena.deinit();
12 const allocator = arena.allocator();
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 iter = CodePointIterator{ .bytes = input };
22 var result: usize = 0;
23 var timer = try std.time.Timer.start();
24
25 while (iter.next()) |_| result += 1;
26 std.debug.print("Ziglyph CodePointIterator: result: {}, took: {}\n", .{ result, timer.lap() / std.time.ns_per_ms });
27}