GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — benchmark: rewrite import.meta benchmark · nodejs/node@23f56d8

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • benchmark
    • esm
      • import-meta.js
    • fixtures
      • esm-dir-file.mjs
      • load-esm-dir-file.js
    • misc
      • startup.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎benchmark/esm/import-meta.js‎

Copy file name to clipboard
+32Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
'use strict';
2+
3+
const path = require('path');
4+
const { pathToFileURL, fileURLToPath } = require('url');
5+
const common = require('../common');
6+
const assert = require('assert');
7+
const bench = common.createBenchmark(main, {
8+
n: [1000],
9+
});
10+
11+
const file = pathToFileURL(
12+
path.resolve(__filename, '../../fixtures/esm-dir-file.mjs'),
13+
);
14+
async function load(array, n) {
15+
for (let i = 0; i < n; i++) {
16+
array[i] = await import(`${file}?i=${i}`);
17+
}
18+
return array;
19+
}
20+
21+
function main({ n }) {
22+
const array = [];
23+
for (let i = 0; i < n; ++i) {
24+
array.push({ dirname: '', filename: '', i: 0 });
25+
}
26+
27+
bench.start();
28+
load(array, n).then((arr) => {
29+
bench.end(n);
30+
assert.strictEqual(arr[n - 1].filename, fileURLToPath(file));
31+
});
32+
}
Collapse file

‎benchmark/fixtures/esm-dir-file.mjs‎

Copy file name to clipboard
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
import assert from 'assert';
2-
assert.ok(import.meta.dirname);
3-
assert.ok(import.meta.filename);
1+
export const dirname = import.meta.dirname;
2+
export const filename = import.meta.filename;
Collapse file

‎benchmark/fixtures/load-esm-dir-file.js‎

Copy file name to clipboardExpand all lines: benchmark/fixtures/load-esm-dir-file.js
-5Lines changed: 0 additions & 5 deletions
This file was deleted.
Collapse file

‎benchmark/misc/startup.js‎

Copy file name to clipboardExpand all lines: benchmark/misc/startup.js
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const bench = common.createBenchmark(main, {
99
script: [
1010
'benchmark/fixtures/require-builtins',
1111
'test/fixtures/semicolon',
12-
'benchmark/fixtures/load-esm-dir-file',
1312
],
1413
mode: ['process', 'worker'],
1514
count: [30],

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.