summaryrefslogtreecommitdiff
path: root/deps/node/benchmark/fs
diff options
context:
space:
mode:
Diffstat (limited to 'deps/node/benchmark/fs')
-rw-r--r--deps/node/benchmark/fs/bench-mkdirp.js23
-rw-r--r--deps/node/benchmark/fs/bench-readdir.js24
-rw-r--r--deps/node/benchmark/fs/bench-readdirSync.js22
-rw-r--r--deps/node/benchmark/fs/bench-realpath.js41
-rw-r--r--deps/node/benchmark/fs/bench-realpathSync.js24
-rw-r--r--deps/node/benchmark/fs/bench-stat-promise.js28
-rw-r--r--deps/node/benchmark/fs/bench-stat.js31
-rw-r--r--deps/node/benchmark/fs/bench-statSync.js26
-rw-r--r--deps/node/benchmark/fs/read-stream-throughput.js90
-rw-r--r--deps/node/benchmark/fs/readFileSync.js15
-rw-r--r--deps/node/benchmark/fs/readfile-partitioned.js86
-rw-r--r--deps/node/benchmark/fs/readfile.js58
-rw-r--r--deps/node/benchmark/fs/write-stream-throughput.js69
13 files changed, 0 insertions, 537 deletions
diff --git a/deps/node/benchmark/fs/bench-mkdirp.js b/deps/node/benchmark/fs/bench-mkdirp.js
deleted file mode 100644
index b9e62045..00000000
--- a/deps/node/benchmark/fs/bench-mkdirp.js
+++ /dev/null
@@ -1,23 +0,0 @@
-'use strict';
-
-const common = require('../common');
-const fs = require('fs');
-const tmpdir = require('../../test/common/tmpdir');
-tmpdir.refresh();
-let dirc = 0;
-
-const bench = common.createBenchmark(main, {
- n: [1e4],
-});
-
-function main({ n }) {
- bench.start();
- (function r(cntr) {
- if (cntr-- <= 0)
- return bench.end(n);
- const pathname = `${tmpdir.path}/${++dirc}/${++dirc}/${++dirc}/${++dirc}`;
- fs.mkdir(pathname, { recursive: true }, (err) => {
- r(cntr);
- });
- }(n));
-}
diff --git a/deps/node/benchmark/fs/bench-readdir.js b/deps/node/benchmark/fs/bench-readdir.js
deleted file mode 100644
index 3731e35a..00000000
--- a/deps/node/benchmark/fs/bench-readdir.js
+++ /dev/null
@@ -1,24 +0,0 @@
-'use strict';
-
-const common = require('../common');
-const fs = require('fs');
-const path = require('path');
-
-const bench = common.createBenchmark(main, {
- n: [10],
- dir: [ 'lib', 'test/parallel'],
- withFileTypes: ['true', 'false']
-});
-
-function main({ n, dir, withFileTypes }) {
- withFileTypes = withFileTypes === 'true';
- const fullPath = path.resolve(__dirname, '../../', dir);
- bench.start();
- (function r(cntr) {
- if (cntr-- <= 0)
- return bench.end(n);
- fs.readdir(fullPath, { withFileTypes }, () => {
- r(cntr);
- });
- }(n));
-}
diff --git a/deps/node/benchmark/fs/bench-readdirSync.js b/deps/node/benchmark/fs/bench-readdirSync.js
deleted file mode 100644
index 5d0e9739..00000000
--- a/deps/node/benchmark/fs/bench-readdirSync.js
+++ /dev/null
@@ -1,22 +0,0 @@
-'use strict';
-
-const common = require('../common');
-const fs = require('fs');
-const path = require('path');
-
-const bench = common.createBenchmark(main, {
- n: [10],
- dir: [ 'lib', 'test/parallel'],
- withFileTypes: ['true', 'false']
-});
-
-
-function main({ n, dir, withFileTypes }) {
- withFileTypes = withFileTypes === 'true';
- const fullPath = path.resolve(__dirname, '../../', dir);
- bench.start();
- for (var i = 0; i < n; i++) {
- fs.readdirSync(fullPath, { withFileTypes });
- }
- bench.end(n);
-}
diff --git a/deps/node/benchmark/fs/bench-realpath.js b/deps/node/benchmark/fs/bench-realpath.js
deleted file mode 100644
index 97148437..00000000
--- a/deps/node/benchmark/fs/bench-realpath.js
+++ /dev/null
@@ -1,41 +0,0 @@
-'use strict';
-
-const common = require('../common');
-const fs = require('fs');
-const path = require('path');
-const resolved_path = path.resolve(__dirname, '../../lib/');
-const relative_path = path.relative(__dirname, '../../lib/');
-
-const bench = common.createBenchmark(main, {
- n: [1e4],
- pathType: ['relative', 'resolved'],
-});
-
-
-function main({ n, pathType }) {
- bench.start();
- if (pathType === 'relative')
- relativePath(n);
- else
- resolvedPath(n);
-}
-
-function relativePath(n) {
- (function r(cntr) {
- if (cntr-- <= 0)
- return bench.end(n);
- fs.realpath(relative_path, () => {
- r(cntr);
- });
- }(n));
-}
-
-function resolvedPath(n) {
- (function r(cntr) {
- if (cntr-- <= 0)
- return bench.end(n);
- fs.realpath(resolved_path, () => {
- r(cntr);
- });
- }(n));
-}
diff --git a/deps/node/benchmark/fs/bench-realpathSync.js b/deps/node/benchmark/fs/bench-realpathSync.js
deleted file mode 100644
index 7a01bd18..00000000
--- a/deps/node/benchmark/fs/bench-realpathSync.js
+++ /dev/null
@@ -1,24 +0,0 @@
-'use strict';
-
-const common = require('../common');
-const fs = require('fs');
-const path = require('path');
-
-process.chdir(__dirname);
-const resolved_path = path.resolve(__dirname, '../../lib/');
-const relative_path = path.relative(__dirname, '../../lib/');
-
-const bench = common.createBenchmark(main, {
- n: [1e4],
- pathType: ['relative', 'resolved'],
-});
-
-
-function main({ n, pathType }) {
- const path = pathType === 'relative' ? relative_path : resolved_path;
- bench.start();
- for (var i = 0; i < n; i++) {
- fs.realpathSync(path);
- }
- bench.end(n);
-}
diff --git a/deps/node/benchmark/fs/bench-stat-promise.js b/deps/node/benchmark/fs/bench-stat-promise.js
deleted file mode 100644
index 99a5da57..00000000
--- a/deps/node/benchmark/fs/bench-stat-promise.js
+++ /dev/null
@@ -1,28 +0,0 @@
-'use strict';
-
-const common = require('../common');
-const fsPromises = require('fs').promises;
-
-const bench = common.createBenchmark(main, {
- n: [20e4],
- statType: ['fstat', 'lstat', 'stat']
-});
-
-async function run(n, statType) {
- const handleMode = statType === 'fstat';
- const arg = handleMode ? await fsPromises.open(__filename, 'r') : __filename;
- let remaining = n;
- bench.start();
- while (remaining-- > 0)
- await (handleMode ? arg.stat() : fsPromises[statType](arg));
- bench.end(n);
-
- if (typeof arg.close === 'function')
- await arg.close();
-}
-
-function main(conf) {
- const n = conf.n >>> 0;
- const statType = conf.statType;
- run(n, statType).catch(console.log);
-}
diff --git a/deps/node/benchmark/fs/bench-stat.js b/deps/node/benchmark/fs/bench-stat.js
deleted file mode 100644
index 0b2e1972..00000000
--- a/deps/node/benchmark/fs/bench-stat.js
+++ /dev/null
@@ -1,31 +0,0 @@
-'use strict';
-
-const common = require('../common');
-const fs = require('fs');
-
-const bench = common.createBenchmark(main, {
- n: [20e4],
- statType: ['fstat', 'lstat', 'stat']
-});
-
-
-function main({ n, statType }) {
- var arg;
- if (statType === 'fstat')
- arg = fs.openSync(__filename, 'r');
- else
- arg = __filename;
-
- bench.start();
- (function r(cntr, fn) {
- if (cntr-- <= 0) {
- bench.end(n);
- if (statType === 'fstat')
- fs.closeSync(arg);
- return;
- }
- fn(arg, () => {
- r(cntr, fn);
- });
- }(n, fs[statType]));
-}
diff --git a/deps/node/benchmark/fs/bench-statSync.js b/deps/node/benchmark/fs/bench-statSync.js
deleted file mode 100644
index bd8754a6..00000000
--- a/deps/node/benchmark/fs/bench-statSync.js
+++ /dev/null
@@ -1,26 +0,0 @@
-'use strict';
-
-const common = require('../common');
-const fs = require('fs');
-
-const bench = common.createBenchmark(main, {
- n: [1e6],
- statSyncType: ['fstatSync', 'lstatSync', 'statSync']
-});
-
-
-function main({ n, statSyncType }) {
- const arg = (statSyncType === 'fstatSync' ?
- fs.openSync(__filename, 'r') :
- __dirname);
- const fn = fs[statSyncType];
-
- bench.start();
- for (var i = 0; i < n; i++) {
- fn(arg);
- }
- bench.end(n);
-
- if (statSyncType === 'fstat')
- fs.closeSync(arg);
-}
diff --git a/deps/node/benchmark/fs/read-stream-throughput.js b/deps/node/benchmark/fs/read-stream-throughput.js
deleted file mode 100644
index cb5d98dc..00000000
--- a/deps/node/benchmark/fs/read-stream-throughput.js
+++ /dev/null
@@ -1,90 +0,0 @@
-// Test the throughput of the fs.WriteStream class.
-'use strict';
-
-const path = require('path');
-const common = require('../common.js');
-const filename = path.resolve(process.env.NODE_TMPDIR || __dirname,
- `.removeme-benchmark-garbage-${process.pid}`);
-const fs = require('fs');
-const assert = require('assert');
-
-let encodingType, encoding, size, filesize;
-
-const bench = common.createBenchmark(main, {
- encodingType: ['buf', 'asc', 'utf'],
- filesize: [1000 * 1024 * 1024],
- size: [1024, 4096, 65535, 1024 * 1024]
-});
-
-function main(conf) {
- encodingType = conf.encodingType;
- size = conf.size;
- filesize = conf.filesize;
-
- switch (encodingType) {
- case 'buf':
- encoding = null;
- break;
- case 'asc':
- encoding = 'ascii';
- break;
- case 'utf':
- encoding = 'utf8';
- break;
- default:
- throw new Error(`invalid encodingType: ${encodingType}`);
- }
-
- makeFile();
-}
-
-function runTest() {
- assert(fs.statSync(filename).size === filesize);
- const rs = fs.createReadStream(filename, {
- highWaterMark: size,
- encoding: encoding
- });
-
- rs.on('open', () => {
- bench.start();
- });
-
- var bytes = 0;
- rs.on('data', (chunk) => {
- bytes += chunk.length;
- });
-
- rs.on('end', () => {
- try { fs.unlinkSync(filename); } catch {}
- // MB/sec
- bench.end(bytes / (1024 * 1024));
- });
-}
-
-function makeFile() {
- const buf = Buffer.allocUnsafe(filesize / 1024);
- if (encoding === 'utf8') {
- // ü
- for (var i = 0; i < buf.length; i++) {
- buf[i] = i % 2 === 0 ? 0xC3 : 0xBC;
- }
- } else if (encoding === 'ascii') {
- buf.fill('a');
- } else {
- buf.fill('x');
- }
-
- try { fs.unlinkSync(filename); } catch {}
- var w = 1024;
- const ws = fs.createWriteStream(filename);
- ws.on('close', runTest);
- ws.on('drain', write);
- write();
- function write() {
- do {
- w--;
- } while (false !== ws.write(buf) && w > 0);
- if (w === 0)
- ws.end();
- }
-}
diff --git a/deps/node/benchmark/fs/readFileSync.js b/deps/node/benchmark/fs/readFileSync.js
deleted file mode 100644
index c28adeb2..00000000
--- a/deps/node/benchmark/fs/readFileSync.js
+++ /dev/null
@@ -1,15 +0,0 @@
-'use strict';
-
-const common = require('../common.js');
-const fs = require('fs');
-
-const bench = common.createBenchmark(main, {
- n: [60e4]
-});
-
-function main({ n }) {
- bench.start();
- for (var i = 0; i < n; ++i)
- fs.readFileSync(__filename);
- bench.end(n);
-}
diff --git a/deps/node/benchmark/fs/readfile-partitioned.js b/deps/node/benchmark/fs/readfile-partitioned.js
deleted file mode 100644
index 2775793e..00000000
--- a/deps/node/benchmark/fs/readfile-partitioned.js
+++ /dev/null
@@ -1,86 +0,0 @@
-// Submit a mix of short and long jobs to the threadpool.
-// Report total job throughput.
-// If we partition the long job, overall job throughput goes up significantly.
-// However, this comes at the cost of the long job throughput.
-//
-// Short jobs: small zip jobs.
-// Long jobs: fs.readFile on a large file.
-
-'use strict';
-
-const path = require('path');
-const common = require('../common.js');
-const filename = path.resolve(__dirname,
- `.removeme-benchmark-garbage-${process.pid}`);
-const fs = require('fs');
-const zlib = require('zlib');
-const assert = require('assert');
-
-const bench = common.createBenchmark(main, {
- dur: [5],
- len: [1024, 16 * 1024 * 1024],
- concurrent: [1, 10]
-});
-
-function main(conf) {
- const len = +conf.len;
- try { fs.unlinkSync(filename); } catch {}
- var data = Buffer.alloc(len, 'x');
- fs.writeFileSync(filename, data);
- data = null;
-
- var zipData = Buffer.alloc(1024, 'a');
-
- var reads = 0;
- var zips = 0;
- var benchEnded = false;
- bench.start();
- setTimeout(() => {
- const totalOps = reads + zips;
- benchEnded = true;
- bench.end(totalOps);
- try { fs.unlinkSync(filename); } catch {}
- }, +conf.dur * 1000);
-
- function read() {
- fs.readFile(filename, afterRead);
- }
-
- function afterRead(er, data) {
- if (er) {
- if (er.code === 'ENOENT') {
- // Only OK if unlinked by the timer from main.
- assert.ok(benchEnded);
- return;
- }
- throw er;
- }
-
- if (data.length !== len)
- throw new Error('wrong number of bytes returned');
-
- reads++;
- if (!benchEnded)
- read();
- }
-
- function zip() {
- zlib.deflate(zipData, afterZip);
- }
-
- function afterZip(er, data) {
- if (er)
- throw er;
-
- zips++;
- if (!benchEnded)
- zip();
- }
-
- // Start reads
- var cur = +conf.concurrent;
- while (cur--) read();
-
- // Start a competing zip
- zip();
-}
diff --git a/deps/node/benchmark/fs/readfile.js b/deps/node/benchmark/fs/readfile.js
deleted file mode 100644
index 551804b1..00000000
--- a/deps/node/benchmark/fs/readfile.js
+++ /dev/null
@@ -1,58 +0,0 @@
-// Call fs.readFile over and over again really fast.
-// Then see how many times it got called.
-// Yes, this is a silly benchmark. Most benchmarks are silly.
-'use strict';
-
-const path = require('path');
-const common = require('../common.js');
-const filename = path.resolve(process.env.NODE_TMPDIR || __dirname,
- `.removeme-benchmark-garbage-${process.pid}`);
-const fs = require('fs');
-const assert = require('assert');
-
-const bench = common.createBenchmark(main, {
- dur: [5],
- len: [1024, 16 * 1024 * 1024],
- concurrent: [1, 10]
-});
-
-function main({ len, dur, concurrent }) {
- try { fs.unlinkSync(filename); } catch {}
- var data = Buffer.alloc(len, 'x');
- fs.writeFileSync(filename, data);
- data = null;
-
- var reads = 0;
- var benchEnded = false;
- bench.start();
- setTimeout(() => {
- benchEnded = true;
- bench.end(reads);
- try { fs.unlinkSync(filename); } catch {}
- process.exit(0);
- }, dur * 1000);
-
- function read() {
- fs.readFile(filename, afterRead);
- }
-
- function afterRead(er, data) {
- if (er) {
- if (er.code === 'ENOENT') {
- // Only OK if unlinked by the timer from main.
- assert.ok(benchEnded);
- return;
- }
- throw er;
- }
-
- if (data.length !== len)
- throw new Error('wrong number of bytes returned');
-
- reads++;
- if (!benchEnded)
- read();
- }
-
- while (concurrent--) read();
-}
diff --git a/deps/node/benchmark/fs/write-stream-throughput.js b/deps/node/benchmark/fs/write-stream-throughput.js
deleted file mode 100644
index bc883309..00000000
--- a/deps/node/benchmark/fs/write-stream-throughput.js
+++ /dev/null
@@ -1,69 +0,0 @@
-// Test the throughput of the fs.WriteStream class.
-'use strict';
-
-const path = require('path');
-const common = require('../common.js');
-const filename = path.resolve(process.env.NODE_TMPDIR || __dirname,
- `.removeme-benchmark-garbage-${process.pid}`);
-const fs = require('fs');
-
-const bench = common.createBenchmark(main, {
- dur: [5],
- encodingType: ['buf', 'asc', 'utf'],
- size: [2, 1024, 65535, 1024 * 1024]
-});
-
-function main({ dur, encodingType, size }) {
- var encoding;
-
- var chunk;
- switch (encodingType) {
- case 'buf':
- chunk = Buffer.alloc(size, 'b');
- break;
- case 'asc':
- chunk = 'a'.repeat(size);
- encoding = 'ascii';
- break;
- case 'utf':
- chunk = 'ü'.repeat(Math.ceil(size / 2));
- encoding = 'utf8';
- break;
- default:
- throw new Error(`invalid encodingType: ${encodingType}`);
- }
-
- try { fs.unlinkSync(filename); } catch {}
-
- var started = false;
- var ended = false;
-
- var f = fs.createWriteStream(filename);
- f.on('drain', write);
- f.on('open', write);
- f.on('close', done);
- f.on('finish', () => {
- ended = true;
- const written = fs.statSync(filename).size / 1024;
- try { fs.unlinkSync(filename); } catch {}
- bench.end(written / 1024);
- });
-
-
- function write() {
- if (!started) {
- started = true;
- setTimeout(() => {
- f.end();
- }, dur * 1000);
- bench.start();
- }
-
- while (false !== f.write(chunk, encoding));
- }
-
- function done() {
- if (!ended)
- f.emit('finish');
- }
-}