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: added new benchmarks for blob · nodejs/node@b707574

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • benchmark/blob
    • clone.js
    • creation.js
    • resolveObjectURL.js
    • slice.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎benchmark/blob/clone.js‎

Copy file name to clipboard
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict';
2+
const common = require('../common.js');
3+
const {
4+
Blob,
5+
} = require('node:buffer');
6+
const assert = require('assert');
7+
8+
const bench = common.createBenchmark(main, {
9+
n: [50e3],
10+
});
11+
12+
let _cloneResult;
13+
14+
function main({ n }) {
15+
bench.start();
16+
for (let i = 0; i < n; ++i)
17+
_cloneResult = structuredClone(new Blob(['hello']));
18+
bench.end(n);
19+
20+
// Avoid V8 deadcode (elimination)
21+
assert.ok(_cloneResult);
22+
}
Collapse file

‎benchmark/blob/creation.js‎

Copy file name to clipboard
+48Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
'use strict';
2+
const common = require('../common.js');
3+
const {
4+
Blob,
5+
} = require('node:buffer');
6+
const assert = require('assert');
7+
8+
const options = {
9+
flags: ['--expose-internals'],
10+
};
11+
12+
const bench = common.createBenchmark(main, {
13+
n: [50e3],
14+
kind: [
15+
'Blob',
16+
'createBlob',
17+
],
18+
}, options);
19+
20+
let _blob;
21+
let _createBlob;
22+
23+
function main({ n, kind }) {
24+
switch (kind) {
25+
case 'Blob': {
26+
bench.start();
27+
for (let i = 0; i < n; ++i)
28+
_blob = new Blob(['hello']);
29+
bench.end(n);
30+
31+
// Avoid V8 deadcode (elimination)
32+
assert.ok(_blob);
33+
break;
34+
} case 'createBlob': {
35+
const { createBlob } = require('internal/blob');
36+
const reusableBlob = new Blob(['hello']);
37+
bench.start();
38+
for (let i = 0; i < n; ++i)
39+
_createBlob = createBlob(reusableBlob, reusableBlob.size);
40+
bench.end(n);
41+
42+
// Avoid V8 deadcode (elimination)
43+
assert.ok(_createBlob);
44+
break;
45+
} default:
46+
throw new Error('Invalid kind');
47+
}
48+
}
Collapse file

‎benchmark/blob/resolveObjectURL.js‎

Copy file name to clipboard
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict';
2+
const common = require('../common.js');
3+
const { Blob, resolveObjectURL } = require('node:buffer');
4+
const assert = require('assert');
5+
6+
const bench = common.createBenchmark(main, {
7+
n: [50e3],
8+
});
9+
10+
let _resolveObjectURL;
11+
12+
function main({ n }) {
13+
const blob = new Blob(['hello']);
14+
const id = URL.createObjectURL(blob);
15+
bench.start();
16+
for (let i = 0; i < n; ++i)
17+
_resolveObjectURL = resolveObjectURL(id);
18+
bench.end(n);
19+
20+
// Avoid V8 deadcode (elimination)
21+
assert.ok(_resolveObjectURL);
22+
}
Collapse file

‎benchmark/blob/slice.js‎

Copy file name to clipboard
+27Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use strict';
2+
const common = require('../common.js');
3+
const { Blob } = require('node:buffer');
4+
const assert = require('assert');
5+
6+
const bench = common.createBenchmark(main, {
7+
n: [50e3],
8+
dataSize: [
9+
5,
10+
30 * 1024,
11+
],
12+
});
13+
14+
let _sliceResult;
15+
16+
function main({ n, dataSize }) {
17+
const data = 'a'.repeat(dataSize);
18+
const reusableBlob = new Blob([data]);
19+
20+
bench.start();
21+
for (let i = 0; i < n; ++i)
22+
_sliceResult = reusableBlob.slice(0, Math.floor(data.length / 2));
23+
bench.end(n);
24+
25+
// Avoid V8 deadcode (elimination)
26+
assert.ok(_sliceResult);
27+
}

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.