import "./profile.js"
// do some stuff...
const items = [...new Array(100)].map((x, i) => i)
for (let i of items) {
setTimeout(() => console.log(`item ${i}`), 150)
}
$ node run.js
[...]
item 98
item 99
mem(total): 21.36MB mem(init): 20.71MB mem(alloc): 0.65MB
time: 164.065ms
samples: 3 interval: 100
By default, the script will sample every 100ms. You can change this with an environment variable:
$ PROFILE_INTERVAL=20 node run.js
[...]
item 98
item 99
mem(total): 21.35MB mem(init): 20.66MB mem(alloc): 0.70MB
time: 167.898ms
samples: 9 interval: 20