Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

lib: add nowAbsolute to fast timers #3749

Merged
merged 1 commit into from
Nov 18, 2024

Conversation

flakey5
Copy link
Member

@flakey5 flakey5 commented Oct 19, 2024

This adds a nowAbsolute function to the fast timers lib that allows for fetching the approximate absolute timestamp. This is useful in places like the cache interceptor and cache stores, where we're currently calling Date.now().

image

cc @mcollina

test/utils/timers.js Outdated Show resolved Hide resolved
test/utils/timers.js Outdated Show resolved Hide resolved
Copy link
Member

@ronag ronag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can't use the no stall timer.

@ronag
Copy link
Member

ronag commented Oct 19, 2024

Add another variable called fastNowAbsolute which is updated to date.now in every refresh

lib/util/timers.js Outdated Show resolved Hide resolved
@@ -0,0 +1,13 @@
import { bench, group, run } from 'mitata'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kind of trivial benchmark.

@flakey5 flakey5 force-pushed the flakey5/20241018/now-absolute branch from 152c924 to eb65121 Compare November 2, 2024 08:24
@mcollina
Copy link
Member

mcollina commented Nov 3, 2024

CI is very red

@mcollina
Copy link
Member

Still very red

@flakey5 flakey5 force-pushed the flakey5/20241018/now-absolute branch from b9d2d1a to a8238fd Compare November 14, 2024 05:03
@mcollina
Copy link
Member

This now conflicts

Signed-off-by: flakey5 <73616808+flakey5@users.noreply.github.com>
@flakey5 flakey5 force-pushed the flakey5/20241018/now-absolute branch from a8238fd to b494bf1 Compare November 18, 2024 17:31
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina merged commit 24df4a5 into nodejs:main Nov 18, 2024
33 of 36 checks passed
@github-actions github-actions bot mentioned this pull request Dec 3, 2024
This was referenced Dec 16, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants