-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into perf-timessync
- Loading branch information
Showing
25 changed files
with
467 additions
and
226 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 |
---|---|---|
|
@@ -23,6 +23,7 @@ on: | |
- corepack | ||
- doc | ||
- eslint | ||
- github_reporter | ||
- googletest | ||
- histogram | ||
- icu | ||
|
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,43 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const fs = require('fs'); | ||
const tmpdir = require('../../test/common/tmpdir'); | ||
tmpdir.refresh(); | ||
|
||
const bench = common.createBenchmark(main, { | ||
type: ['existing', 'non-existing'], | ||
n: [1e3], | ||
}); | ||
|
||
function main({ n, type }) { | ||
let files; | ||
|
||
switch (type) { | ||
case 'existing': | ||
files = []; | ||
|
||
// Populate tmpdir with mock files | ||
for (let i = 0; i < n; i++) { | ||
const path = tmpdir.resolve(`unlinksync-bench-file-${i}`); | ||
fs.writeFileSync(path, 'bench'); | ||
files.push(path); | ||
} | ||
break; | ||
case 'non-existing': | ||
files = new Array(n).fill(tmpdir.resolve(`.non-existing-file-${Date.now()}`)); | ||
break; | ||
default: | ||
new Error('Invalid type'); | ||
} | ||
|
||
bench.start(); | ||
for (let i = 0; i < n; i++) { | ||
try { | ||
fs.unlinkSync(files[i]); | ||
} catch { | ||
// do nothing | ||
} | ||
} | ||
bench.end(n); | ||
} |
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
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,36 @@ | ||
'use strict'; | ||
|
||
const assert = require('assert'); | ||
const common = require('../common.js'); | ||
|
||
const { | ||
PerformanceObserver, | ||
performance, | ||
} = require('perf_hooks'); | ||
|
||
function randomFn() { | ||
return Math.random(); | ||
} | ||
|
||
const bench = common.createBenchmark(main, { | ||
n: [1e5], | ||
observe: ['function'], | ||
}); | ||
|
||
let _result; | ||
|
||
function main({ n, observe }) { | ||
const obs = new PerformanceObserver(() => { | ||
bench.end(n); | ||
}); | ||
obs.observe({ entryTypes: [observe], buffered: true }); | ||
|
||
const timerfied = performance.timerify(randomFn); | ||
|
||
bench.start(); | ||
for (let i = 0; i < n; i++) | ||
_result = timerfied(); | ||
|
||
// Avoid V8 deadcode (elimination) | ||
assert.ok(_result); | ||
} |
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,23 @@ | ||
'use strict'; | ||
const common = require('../common.js'); | ||
const url = require('url'); | ||
const URL = url.URL; | ||
|
||
const bench = common.createBenchmark(main, { | ||
type: ['valid', 'invalid'], | ||
e: [1e5], | ||
}); | ||
|
||
// This benchmark is used to compare the `Invalid URL` path of the URL parser | ||
function main({ type, e }) { | ||
const url = type === 'valid' ? 'https://www.nodejs.org' : 'www.nodejs.org'; | ||
bench.start(); | ||
for (let i = 0; i < e; i++) { | ||
try { | ||
new URL(url); | ||
} catch { | ||
// do nothing | ||
} | ||
} | ||
bench.end(e); | ||
} |
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
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
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
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
Oops, something went wrong.