blob: a6203a3a9039339129aac0bd246a3f11b3d3b699 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
const std = @import("std");
fn benchmark(name: []const u8, iters: usize, func: fn () anyerror!void) !void {
var timer = try std.time.Timer.start();
for (0..iters) |i| {
_ = i;
try func();
}
const ns: f64 = @floatFromInt(timer.lap());
const secs = ns / 1_000_000_000;
std.debug.print(
"bench {s} x {}: {d:.3}s\n",
.{ name, iters, secs },
);
}
|