Guest User

Untitled

a guest
Oct 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. const timing = callback => {
  2.  
  3. // Get the start time using performance.now()
  4. const start = performance.now();
  5.  
  6. // Perform the asynchronous operation
  7. // Finally, log the time difference
  8.  
  9. return Promise.resolve(callback())
  10. .finally(() => console.log(`Timing: ${performance.now() - start}`));
  11.  
  12. };
Add Comment
Please, Sign In to add comment