Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/gc.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,14 @@ class GCEntry {
[kSample] (ns) {
this[kTotalDuration] += ns
/**
* We have to truncate the value here because `record`
* We have to adjust the value here because `record`
* only accepts integer values:
* https://github.com/nodejs/node/blob/cdad3d8fe5f468aec6549fd59db73a3bfe063e3c/lib/internal/histogram.js#L283-L284
*/
this[kHistogram].record(Math.trunc(ns))
const val = Math.round(ns)
if (val > 0) {
this[kHistogram].record(val)
}
}

[kReset] () {
Expand Down
3 changes: 2 additions & 1 deletion test/doc.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ test('custom sample interval', t => {
const end = process.hrtime(start)
const elapsed = hrtime2ms(end)
const message = `expected: value >= 2000, value: ${elapsed}`
t.ok(elapsed >= 2000, message)
// For some reason in the CI this is around 1999
t.ok(elapsed >= 1900, message)
t.end()
})
})
Expand Down