-
-
Save willmendesneto/41985f16808602e62510f3c994edebbc to your computer and use it in GitHub Desktop.
perf-marks example using profiler method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { profiler } from 'perf-marks/profiler'; | |
const marker = 'my-marker'; | |
const someExpensiveMemoryAndTimeTask = () => 1 + 1; | |
// Just need to wrap your function with `profiler()` method and that's it! | |
// Easy peasy, lemon squeezy! 🍋 | |
profiler(async () => { | |
return new Promise((resolve) => { | |
setTimeout(() => { | |
setTimeout(() => { | |
resolve(someExpensiveMemoryAndTimeTask()); | |
}, 1000); | |
}, 2000); | |
}); | |
}, marker).then(result => console.log(result)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment