Skip to content

Instantly share code, notes, and snippets.

@deepal
Last active March 11, 2022 20:59
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/f3353a6ac9515676ee2904015a6fa55e to your computer and use it in GitHub Desktop.
Save deepal/f3353a6ac9515676ee2904015a6fa55e to your computer and use it in GitHub Desktop.
setFakeTime(); // set time to 1 min ahead of actual time
const startTimeToD = Date.now(); // set startTime with time-of-day clock
setImmediate(() => {
correctTimeNTP(); // synchronise the clock
});
await doSomething();
const endTimeToD = Date.now(); // set endTime with time-of-day clock
const durationToD = endTimeToD - startTimeToD;
console.log(`Duration measured by time-of-day clock\t: ${durationToD}ms`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment