-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf_hooks: reduce overhead of createHistogram
PR-URL: #50074 Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]>
- Loading branch information
Showing
3 changed files
with
82 additions
and
20 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,24 @@ | ||
'use strict'; | ||
|
||
const assert = require('assert'); | ||
const common = require('../common.js'); | ||
|
||
const { createHistogram } = require('perf_hooks'); | ||
|
||
const bench = common.createBenchmark(main, { | ||
n: [1e5], | ||
}); | ||
|
||
let _histogram; | ||
|
||
function main({ n }) { | ||
const histogram = createHistogram(); | ||
|
||
bench.start(); | ||
for (let i = 0; i < n; i ) | ||
_histogram = structuredClone(histogram); | ||
bench.end(n); | ||
|
||
// Avoid V8 deadcode (elimination) | ||
assert.ok(_histogram); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,22 @@ | ||
'use strict'; | ||
|
||
const assert = require('assert'); | ||
const common = require('../common.js'); | ||
|
||
const { createHistogram } = require('perf_hooks'); | ||
|
||
const bench = common.createBenchmark(main, { | ||
n: [1e5], | ||
}); | ||
|
||
let _histogram; | ||
|
||
function main({ n }) { | ||
bench.start(); | ||
for (let i = 0; i < n; i ) | ||
_histogram = createHistogram(); | ||
bench.end(n); | ||
|
||
// Avoid V8 deadcode (elimination) | ||
assert.ok(_histogram); | ||
} |
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