Skip to content

Instantly share code, notes, and snippets.

@vilmid
Last active June 24, 2021 00:52
Show Gist options
  • Select an option

  • Save vilmid/0c9a76bb55de952515424fcd91f39da0 to your computer and use it in GitHub Desktop.

Select an option

Save vilmid/0c9a76bb55de952515424fcd91f39da0 to your computer and use it in GitHub Desktop.
const startTime = performance.now()
await doSomething()
const endTime = performance.now()
const elapsedTimeInSeconds = (endTime - startTime) / 1e+3;
console.log(elapsedTimeInSeconds)
async function doSomething() {
await sleep(3000)
}
async function sleep(ms) {
await new Promise(resolve => setTimeout(resolve, ms))
}
<?php
$startTime = hrtime(true);
doSomething();
$endTime = hrtime(true);
$elapsedTimeInSeconds = ($endTime - $startTime) / 1e+9;
print $elapsedTimeInSeconds;
function doSomething(): void
{
sleep(3);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment