summaryrefslogtreecommitdiff
path: root/benchmark/fs
diff options
context:
space:
mode:
authorCharlie Duong <charlieduong94@gmail.com>2017-10-06 13:00:46 -0700
committerRich Trott <rtrott@gmail.com>2017-10-10 22:59:09 -0700
commit58d26e2421358698415f214f28d18b37ff77f12a (patch)
tree8c96202626eef9c11be2d21a1d65b71267c095f3 /benchmark/fs
parent7525df7af20b565220076deac932ec652da13304 (diff)
downloadandroid-node-v8-58d26e2421358698415f214f28d18b37ff77f12a.tar.gz
android-node-v8-58d26e2421358698415f214f28d18b37ff77f12a.tar.bz2
android-node-v8-58d26e2421358698415f214f28d18b37ff77f12a.zip
test: added fs benchmark test
Modified fs benchmarks to use more unique args to avoid collision. PR-URL: https://github.com/nodejs/node/pull/16049 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Diffstat (limited to 'benchmark/fs')
-rw-r--r--benchmark/fs/bench-realpath.js10
-rw-r--r--benchmark/fs/bench-realpathSync.js10
-rw-r--r--benchmark/fs/bench-stat.js10
-rw-r--r--benchmark/fs/bench-statSync.js12
-rw-r--r--benchmark/fs/read-stream-throughput.js13
-rw-r--r--benchmark/fs/write-stream-throughput.js8
6 files changed, 33 insertions, 30 deletions
diff --git a/benchmark/fs/bench-realpath.js b/benchmark/fs/bench-realpath.js
index d6818d45a5..881bd0031f 100644
--- a/benchmark/fs/bench-realpath.js
+++ b/benchmark/fs/bench-realpath.js
@@ -8,21 +8,21 @@ const relative_path = path.relative(__dirname, '../../lib/');
const bench = common.createBenchmark(main, {
n: [1e4],
- type: ['relative', 'resolved'],
+ pathType: ['relative', 'resolved'],
});
function main(conf) {
const n = conf.n >>> 0;
- const type = conf.type;
+ const pathType = conf.pathType;
bench.start();
- if (type === 'relative')
+ if (pathType === 'relative')
relativePath(n);
- else if (type === 'resolved')
+ else if (pathType === 'resolved')
resolvedPath(n);
else
- throw new Error(`unknown "type": ${type}`);
+ throw new Error(`unknown "pathType": ${pathType}`);
}
function relativePath(n) {
diff --git a/benchmark/fs/bench-realpathSync.js b/benchmark/fs/bench-realpathSync.js
index 27a66631ab..2239d9748a 100644
--- a/benchmark/fs/bench-realpathSync.js
+++ b/benchmark/fs/bench-realpathSync.js
@@ -10,21 +10,21 @@ const relative_path = path.relative(__dirname, '../../lib/');
const bench = common.createBenchmark(main, {
n: [1e4],
- type: ['relative', 'resolved'],
+ pathType: ['relative', 'resolved'],
});
function main(conf) {
const n = conf.n >>> 0;
- const type = conf.type;
+ const pathType = conf.pathType;
bench.start();
- if (type === 'relative')
+ if (pathType === 'relative')
relativePath(n);
- else if (type === 'resolved')
+ else if (pathType === 'resolved')
resolvedPath(n);
else
- throw new Error(`unknown "type": ${type}`);
+ throw new Error(`unknown "pathType": ${pathType}`);
bench.end(n);
}
diff --git a/benchmark/fs/bench-stat.js b/benchmark/fs/bench-stat.js
index 149b4f3d3b..05910d3fc3 100644
--- a/benchmark/fs/bench-stat.js
+++ b/benchmark/fs/bench-stat.js
@@ -5,15 +5,15 @@ const fs = require('fs');
const bench = common.createBenchmark(main, {
n: [20e4],
- kind: ['fstat', 'lstat', 'stat']
+ statType: ['fstat', 'lstat', 'stat']
});
function main(conf) {
const n = conf.n >>> 0;
- const kind = conf.kind;
+ const statType = conf.statType;
var arg;
- if (kind === 'fstat')
+ if (statType === 'fstat')
arg = fs.openSync(__filename, 'r');
else
arg = __filename;
@@ -22,12 +22,12 @@ function main(conf) {
(function r(cntr, fn) {
if (cntr-- <= 0) {
bench.end(n);
- if (kind === 'fstat')
+ if (statType === 'fstat')
fs.closeSync(arg);
return;
}
fn(arg, function() {
r(cntr, fn);
});
- }(n, fs[kind]));
+ }(n, fs[statType]));
}
diff --git a/benchmark/fs/bench-statSync.js b/benchmark/fs/bench-statSync.js
index 57e03df3b0..901f3f1bee 100644
--- a/benchmark/fs/bench-statSync.js
+++ b/benchmark/fs/bench-statSync.js
@@ -5,15 +5,17 @@ const fs = require('fs');
const bench = common.createBenchmark(main, {
n: [1e6],
- kind: ['fstatSync', 'lstatSync', 'statSync']
+ statSyncType: ['fstatSync', 'lstatSync', 'statSync']
});
function main(conf) {
const n = conf.n >>> 0;
- const kind = conf.kind;
- const arg = (kind === 'fstatSync' ? fs.openSync(__filename, 'r') : __dirname);
- const fn = fs[conf.kind];
+ const statSyncType = conf.statSyncType;
+ const arg = (statSyncType === 'fstatSync' ?
+ fs.openSync(__filename, 'r') :
+ __dirname);
+ const fn = fs[statSyncType];
bench.start();
for (var i = 0; i < n; i++) {
@@ -21,6 +23,6 @@ function main(conf) {
}
bench.end(n);
- if (kind === 'fstat')
+ if (statSyncType === 'fstat')
fs.closeSync(arg);
}
diff --git a/benchmark/fs/read-stream-throughput.js b/benchmark/fs/read-stream-throughput.js
index 6cacc026ef..4412d41f98 100644
--- a/benchmark/fs/read-stream-throughput.js
+++ b/benchmark/fs/read-stream-throughput.js
@@ -5,21 +5,22 @@ const path = require('path');
const common = require('../common.js');
const filename = path.resolve(__dirname, '.removeme-benchmark-garbage');
const fs = require('fs');
-const filesize = 1000 * 1024 * 1024;
const assert = require('assert');
-var type, encoding, size;
+let encodingType, encoding, size, filesize;
const bench = common.createBenchmark(main, {
- type: ['buf', 'asc', 'utf'],
+ encodingType: ['buf', 'asc', 'utf'],
+ filesize: [1000 * 1024 * 1024],
size: [1024, 4096, 65535, 1024 * 1024]
});
function main(conf) {
- type = conf.type;
+ encodingType = conf.encodingType;
size = +conf.size;
+ filesize = conf.filesize;
- switch (type) {
+ switch (encodingType) {
case 'buf':
encoding = null;
break;
@@ -30,7 +31,7 @@ function main(conf) {
encoding = 'utf8';
break;
default:
- throw new Error('invalid type');
+ throw new Error(`invalid encodingType: ${encodingType}`);
}
makeFile(runTest);
diff --git a/benchmark/fs/write-stream-throughput.js b/benchmark/fs/write-stream-throughput.js
index 1bdb4bcd66..2083cccbd6 100644
--- a/benchmark/fs/write-stream-throughput.js
+++ b/benchmark/fs/write-stream-throughput.js
@@ -8,18 +8,18 @@ const fs = require('fs');
const bench = common.createBenchmark(main, {
dur: [5],
- type: ['buf', 'asc', 'utf'],
+ encodingType: ['buf', 'asc', 'utf'],
size: [2, 1024, 65535, 1024 * 1024]
});
function main(conf) {
const dur = +conf.dur;
- const type = conf.type;
+ const encodingType = conf.encodingType;
const size = +conf.size;
var encoding;
var chunk;
- switch (type) {
+ switch (encodingType) {
case 'buf':
chunk = Buffer.alloc(size, 'b');
break;
@@ -32,7 +32,7 @@ function main(conf) {
encoding = 'utf8';
break;
default:
- throw new Error('invalid type');
+ throw new Error(`invalid encodingType: ${encodingType}`);
}
try { fs.unlinkSync(filename); } catch (e) {}