Skip to content

Instantly share code, notes, and snippets.

@deepal
Last active March 15, 2022 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deepal/48425db8c9e13ee46ce463fbc2648780 to your computer and use it in GitHub Desktop.
Save deepal/48425db8c9e13ee46ce463fbc2648780 to your computer and use it in GitHub Desktop.
setFakeTime();
const startTimeMon = performance.now(); // set startTime with monotonic clock
setImmediate(() => {
correctTimeNTP(); // synchronise the clock
});
await doSomething();
const endTimeMon = performance.now(); // set endTime with monotonic clock
const durationMon = endTimeMon - startTimeMon;
console.log(`Duration measured by monotonic clock\t: ${durationMon}ms`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment