diff options
| author | patrick-scho | 2025-08-01 11:48:25 +0200 |
|---|---|---|
| committer | patrick-scho | 2025-08-01 11:48:25 +0200 |
| commit | 817decdb855f81136001a5fa544eb8396202d475 (patch) | |
| tree | 8418fecc6d54b8759446ff1f36531f6acae3daed /timer.zig | |
| parent | 997844fc22fdd86f2cd2b7886cfc2dd57939b720 (diff) | |
| download | onefile-817decdb855f81136001a5fa544eb8396202d475.tar.gz onefile-817decdb855f81136001a5fa544eb8396202d475.zip | |
add timer.zig
Diffstat (limited to 'timer.zig')
| -rw-r--r-- | timer.zig | 14 |
1 files changed, 14 insertions, 0 deletions
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); + } +} |
