summaryrefslogtreecommitdiff
path: root/src/test/bench.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/bench.zig')
-rw-r--r--src/test/bench.zig9
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",