-
Notifications
You must be signed in to change notification settings - Fork 288
Performance now #636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance now #636
Conversation
33311ef to
d6eb6d2
Compare
| // Monotonically increasing | ||
| var now = perf._now(); | ||
| while (now <= 0) { // Loop for now to not be 0 | ||
| try testing.expectEqual(now, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parameters are swapped, it's expected, actual /shrug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take this change into the next PR
| } | ||
|
|
||
| pub fn get_timeOrigin(self: *const Performance) f64 { | ||
| const is_posix = switch (@import("builtin").os.tag) { // From std.time.zig L125 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine, but just FYI, build.zig blocks any builds that aren't on linux or macos. There are a few places, like browser.zig timestamp function, which treat anything else as unreachable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, this is ugly. I wanted to just use the is_posix constant in time.zig, but that is not pub for some reason.
Then wanted to just check if @TypeOf(std.time.Instant.timestamp) == i64 but also:
const ts_field = @typeInfo(std.time.Instant).@"struct".fields[0];
if (!std.mem.eql(u8, ts_field.name, "timestamp")) @compileError(ts_field.name);
const is_i64 = ts_field.type == i64;
Does not seem to work ..
|
LGTM |
Initial implementation of 2 interfaces of performance
https://developer.mozilla.org/en-US/docs/Web/API/Performance/timeOrigin
https://developer.mozilla.org/en-US/docs/Web/API/Performance/now
many still TODO
Performance implementation as part of Window, WorkerGlobalScope not implemented.
These APIs are implemented as part of making Playwright click work.