Skip to content

Instantly share code, notes, and snippets.

@Gaafar
Last active July 29, 2019 00:23
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 Gaafar/de12a44a03ef9aa1028fbbc6f58f5d3c to your computer and use it in GitHub Desktop.
Save Gaafar/de12a44a03ef9aa1028fbbc6f58f5d3c to your computer and use it in GitHub Desktop.
record-time-promise.js
const recordTime = (makeRequest) => {
const timeStart = Date.now();
makeRequest().then(() => { // throws error for sync functions (.then is not a function)
const timeEnd = Date.now();
console.log('time take:', timeEnd - timeStart);
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment