This commit is contained in:
Dylan Conway
2025-05-01 21:16:17 -07:00
parent 3bf7e61199
commit b8e2677c0c
3 changed files with 4 additions and 4 deletions

View File

@@ -50,7 +50,7 @@ pub fn update(this: *WTFTimer, seconds: f64, repeat: bool) void {
}
const modf = std.math.modf(seconds);
var interval: timespec = if (Environment.isWindows) .fromMs(uv.uv_now(this.vm.uvLoop())) else timespec.now();
var interval = this.vm.now();
interval.sec += @intFromFloat(modf.ipart);
interval.nsec += @intFromFloat(modf.fpart * std.time.ns_per_s);
if (interval.nsec >= std.time.ns_per_s) {
@@ -131,7 +131,7 @@ export fn WTFTimer__secondsUntilTimer(this: *WTFTimer) f64 {
this.lock.lock();
defer this.lock.unlock();
if (this.event_loop_timer.state == .ACTIVE) {
const now: timespec = if (Environment.isWindows) .fromMs(uv.uv_now(this.vm.uvLoop())) else timespec.now();
const now = this.vm.now();
const until = this.event_loop_timer.next.duration(&now);
const sec: f64, const nsec: f64 = .{ @floatFromInt(until.sec), @floatFromInt(until.nsec) };
return sec + nsec / std.time.ns_per_s;

View File

@@ -1973,7 +1973,7 @@ pub const DNSResolver = struct {
}
this.ref();
this.event_loop_timer.next = (now orelse &timespec.now()).addMs(1000);
this.event_loop_timer.next = (now orelse &this.vm.now()).addMs(1000);
this.vm.timer.incrementTimerRef(1);
this.vm.timer.insert(&this.event_loop_timer);
return true;

View File

@@ -685,7 +685,7 @@ pub const TestScope = struct {
debug("test({})", .{bun.fmt.QuotedFormatter{ .text = this.label }});
var initial_value = JSValue.zero;
task.started_at = bun.timespec.now();
task.started_at = vm.now();
if (this.timeout_millis == std.math.maxInt(u32)) {
if (Jest.runner.?.default_timeout_override != std.math.maxInt(u32)) {