Heyo,
I’m trying to migrate all my stuff to 0.16.0 and can’t find an equivalent to std.time.Timer (0.15.2) in the stdlib. Has it been removed or am I just struggling to find a renamed version of it?
https://codeberg.org/ziglang/zig/commit/922ab8b8bc3b6dc14da9393b65ca2601f9a82728
this is the commit where it gets removed and replaced, I will try to migrate Timestamp as was done in several places here.
You can use std.Io.Clock.
For example:
const std = @import("std");
pub fn main(init: std.process.Init) !void {
const io = init.io;
const start = std.Io.Clock.awake.now(io);
const elapsed = start.untilNow(io, .awake);
std.debug.print("Took {} ns\n", .{elapsed.toNanoseconds()});
}
2 Likes
That looks even better, thank you!
Edit: lol its literally the same thing