Skip to content

Instantly share code, notes, and snippets.

@willmendesneto
Last active Mar 29, 2021
Embed
What would you like to do?
perf-marks example using profiler method
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