summaryrefslogtreecommitdiff
path: root/bench/src/zg_width.zig
diff options
context:
space:
mode:
authorGravatar Sam Atman2025-07-08 12:15:32 -0400
committerGravatar Sam Atman2025-07-08 12:15:32 -0400
commit9427a9e53aaa29ee071f4dcb35b809a699d75aa9 (patch)
tree2607c185fd8053b84d60041fadc35c05a0225d34 /bench/src/zg_width.zig
parentMerge pull request 'Fix benchmarks' (#56) from jacobsandlund/zg:benchmarks in... (diff)
parentAdd Words.zig example to README (diff)
downloadzg-master.tar.gz
zg-master.tar.xz
zg-master.zip
Merge branch 'develop-next'HEADv0.14.1master
Diffstat (limited to 'bench/src/zg_width.zig')
-rw-r--r--bench/src/zg_width.zig32
1 files changed, 0 insertions, 32 deletions
diff --git a/bench/src/zg_width.zig b/bench/src/zg_width.zig
deleted file mode 100644
index b2db3fa..0000000
--- a/bench/src/zg_width.zig
+++ /dev/null
@@ -1,32 +0,0 @@
1const std = @import("std");
2
3const DisplayWidth = @import("DisplayWidth");
4
5pub 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 const display_width = try DisplayWidth.init(allocator);
22
23 var iter = std.mem.splitScalar(u8, input, '\n');
24 var result: usize = 0;
25 var timer = try std.time.Timer.start();
26
27 while (iter.next()) |line| {
28 const width = display_width.strWidth(line);
29 result += width;
30 }
31 std.debug.print("zg DisplayWidth.strWidth: result: {}, took: {}\n", .{ result, std.fmt.fmtDuration(timer.lap()) });
32}