I have this code:
const std = @import("std");
const print = std.debug.print;
pub fn now() u128 {
return @bitCast(std.time.nanoTimestamp());
}
pub fn fibonacci(n: u64) u64 {
return if (n <= 1) 0 else (fibonacci(n - 1) + fibonacci(n - 2));
}
pub fn main() void {
const N = 1000;
const start = now();
for (0..N) |_| {
std.mem.doNotOptimizeAway(fibonacci(25));
}
const elapsed = now() - start;
const avg = @as(f64, @floatFromInt(elapsed)) / @as(f64, @floatFromInt(N));
print("Average: {d}ns", .{avg});
}
but when I run it with zig build run --release=fast, it shows that the elapsed time is zero... anyone know what's going on here?