From: patrick-scho Date: Fri, 1 Aug 2025 09:48:25 +0000 (+0200) Subject: add timer.zig X-Git-Url: https://gitweb.ps.run/onefile/commitdiff_plain/817decdb855f81136001a5fa544eb8396202d475 add timer.zig --- diff --git a/timer.zig b/timer.zig new file mode 100644 index 0000000..874aee3 --- /dev/null +++ b/timer.zig @@ -0,0 +1,14 @@ +const std = @import("std"); + +pub fn main() !void { + var timer = try std.time.Timer.start(); + while (true) { + const ns = timer.read(); + const h = (ns / 1000000000 / 3600); + const m = (ns / 1000000000 / 60) % 60; + const s = (ns / 1000000000) % 60; + const ms = (ns / 1000000) % 1000; + std.debug.print("\r{:0>1}:{:0>2}:{:0>2}.{:0<3}", .{h, m, s, ms}); + std.Thread.sleep(10000000); + } +}