-
Notifications
You must be signed in to change notification settings - Fork 30k
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' of https://github.com/nodejs/node into fork
- Loading branch information
Showing
12 changed files
with
215 additions
and
40 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,32 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
const { pathToFileURL, fileURLToPath } = require('url'); | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const bench = common.createBenchmark(main, { | ||
n: [1000], | ||
}); | ||
|
||
const file = pathToFileURL( | ||
path.resolve(__filename, '../../fixtures/esm-dir-file.mjs'), | ||
); | ||
async function load(array, n) { | ||
for (let i = 0; i < n; i++) { | ||
array[i] = await import(`${file}?i=${i}`); | ||
} | ||
return array; | ||
} | ||
|
||
function main({ n }) { | ||
const array = []; | ||
for (let i = 0; i < n; ++i) { | ||
array.push({ dirname: '', filename: '', i: 0 }); | ||
} | ||
|
||
bench.start(); | ||
load(array, n).then((arr) => { | ||
bench.end(n); | ||
assert.strictEqual(arr[n - 1].filename, fileURLToPath(file)); | ||
}); | ||
} |
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 |
---|---|---|
@@ -1,3 +1,2 @@ | ||
import assert from 'assert'; | ||
assert.ok(import.meta.dirname); | ||
assert.ok(import.meta.filename); | ||
export const dirname = import.meta.dirname; | ||
export const filename = import.meta.filename; |
This file was deleted.
Oops, something went wrong.
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,23 @@ | ||
'use strict'; | ||
|
||
const assert = require('assert'); | ||
const common = require('../common.js'); | ||
|
||
const bench = common.createBenchmark(main, { | ||
n: [1e6], | ||
}); | ||
|
||
function main({ n }) { | ||
const arr = []; | ||
for (let i = 0; i < n; ++i) { | ||
arr.push(performance.now()); | ||
} | ||
|
||
bench.start(); | ||
for (let i = 0; i < n; i++) { | ||
arr[i] = performance.now(); | ||
} | ||
bench.end(n); | ||
|
||
assert.strictEqual(arr.length, 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
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.