diff options
| author | Taylan Kammer <taylan.kammer@gmail.com> | 2026-06-04 19:47:54 +0200 |
|---|---|---|
| committer | Taylan Kammer <taylan.kammer@gmail.com> | 2026-06-04 19:47:54 +0200 |
| commit | cd25a1acae128b660f60a0132ffb981e08442cd4 (patch) | |
| tree | b1f86022131d68a2ea085fa53119fb8d0a89dbcc /src/test/bench.zig | |
| parent | a2315e8df140d8cc58da39942f471e9b8df19ba7 (diff) | |
Fix tests.
Diffstat (limited to 'src/test/bench.zig')
| -rw-r--r-- | src/test/bench.zig | 9 |
1 files changed, 7 insertions, 2 deletions
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", |
