Improve clocks

There's a flaky performance test that I wanted to fix (1). This led to a couple
changes.

1 - Add timestamp() and milliTimestamp() to datetime.zig. Reduce some code
    duplication and use better clock_ids where available

2 - Change Performance API to use milliTimestamp and store a u64 instead of a
    f64. While the spec says a float, Firefox deals with u64 and implicit
    conversion is always available. Makes our APIs simpler.

(1) - https://github.com/lightpanda-io/browser/actions/runs/17313296490/job/49151366798#step:4:131
This commit is contained in:
Karl Seguin
2025-08-30 13:36:02 +08:00
parent d02ba777f2
commit ada9ddd5b8
7 changed files with 61 additions and 45 deletions

View File

@@ -321,14 +321,14 @@ fn writeString(comptime format: Format, value: []const u8, writer: anytype) !voi
return writer.writeByte('"');
}
fn timestamp() i64 {
fn timestamp() u64 {
if (comptime @import("builtin").is_test) {
return 1739795092929;
}
return std.time.milliTimestamp();
return @import("datetime.zig").milliTimestamp();
}
var first_log: i64 = 0;
var first_log: u64 = 0;
fn elapsed() struct { time: f64, unit: []const u8 } {
const now = timestamp();