blob: 39e4a78222d7cae680d4092307a1605ad12271a4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
const std = @import("std");
const Timer = @This();
begin: i128 = 0,
elapsed: i128 = 0,
pub fn start(timer: *Timer) void {
timer.begin = std.time.nanoTimestamp();
}
pub fn stop(timer: *Timer) void {
timer.elapsed = std.time.nanoTimestamp() - timer.begin;
}
pub fn seconds(timer: *const Timer) f64 {
return @intToFloat(f64, timer.elapsed) / std.time.ns_per_s;
}
pub const Group = struct {};
|