From cd25a1acae128b660f60a0132ffb981e08442cd4 Mon Sep 17 00:00:00 2001 From: Taylan Kammer Date: Thu, 4 Jun 2026 19:47:54 +0200 Subject: Fix tests. --- src/test/bench.zig | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/test/bench.zig') diff --git a/src/test/bench.zig b/src/test/bench.zig index a6203a3..6e21df0 100644 --- a/src/test/bench.zig +++ b/src/test/bench.zig @@ -1,12 +1,17 @@ const std = @import("std"); +const Ts = std.Io.Timestamp; + fn benchmark(name: []const u8, iters: usize, func: fn () anyerror!void) !void { - var timer = try std.time.Timer.start(); + const io = std.Io.Threaded.global_single_threaded.io(); + const clock = std.Io.Clock.cpu_thread; + const start = clock.now(io); for (0..iters) |i| { _ = i; try func(); } - const ns: f64 = @floatFromInt(timer.lap()); + const stop = clock.now(io); + const ns: f64 = @floatFromInt(start.durationTo(stop).nanoseconds); const secs = ns / 1_000_000_000; std.debug.print( "bench {s} x {}: {d:.3}s\n", -- cgit v1.2.3