-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(bench): update now() to only OPTIONALLY use bigint timestamps
- Loading branch information
1 parent
aa4faed
commit 7ac391b
Showing
4 changed files
with
32 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
let M: bigint; | ||
|
||
/** | ||
* If available, returns wrapper for `process.hrtime.bigint()` else | ||
* falls back to `Date.now()` (scaled to nanoseconds). In all cases, | ||
* returns a `bigint` timestamp. | ||
*/ | ||
export const now = | ||
typeof process !== "undefined" && | ||
typeof process.hrtime !== "undefined" && | ||
typeof process.hrtime.bigint === "function" | ||
? () => process.hrtime.bigint() | ||
: () => BigInt(Date.now()) * 1_000_000n; | ||
typeof BigInt !== "undefined" | ||
? typeof process !== "undefined" && | ||
typeof process.hrtime !== "undefined" && | ||
typeof process.hrtime.bigint === "function" | ||
? () => process.hrtime.bigint() | ||
: ((M = BigInt(1_000_000)), () => BigInt(Date.now()) * M) | ||
: () => Date.now(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters