-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgcAggregate.js
More file actions
34 lines (29 loc) · 785 Bytes
/
Copy pathgcAggregate.js
File metadata and controls
34 lines (29 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'use strict'
const doc = require('..')
// Keep the event loop alive
const noop = () => {}
setInterval(noop, 1000)
// Initialize a sampler with the default options
const sampler = doc({
gcOptions: {
aggregate: true,
flags: false
},
collect: {
gc: true
}
})
// On sample callback
const onSample = () => {
console.table({
cpu: sampler.cpu.usage,
...sampler.memory,
eventLoopDelay: sampler.eventLoopDelay.computed,
eventLoopUtilization: doc.eventLoopUtilizationSupported ? sampler.eventLoopUtilization.utilization : 'Not Supported',
gc: sampler.gc.pause.mean,
'gc(99)': sampler.gc.pause.getPercentile(99),
'gc.minor': sampler.gc.minor.mean,
'gc.minor(99)': sampler.gc.minor.getPercentile(99)
})
}
sampler.on('sample', onSample)