mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-17 08:48:58 +00:00
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:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user