Skip to content

Commit

Permalink
benchmark: make temp file path configurable
Browse files Browse the repository at this point in the history
In three fs benchmarks, a temp file is created in the source tree. For
tests, allow the location to be configurable so it gets written to the
test temp directory instead.

Additionally, shave about a second off the test running time by setting
`dur` to `0.1` instead of `1`.

PR-URL: #17811
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
  • Loading branch information
Trott authored and apapirovski committed Dec 24, 2017
1 parent 4444b6b commit d610fad
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion benchmark/fs/read-stream-throughput.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

const path = require('path');
const common = require('../common.js');
const filename = path.resolve(__dirname,
const filename = path.resolve(process.env.NODE_TMPDIR || __dirname,
`.removeme-benchmark-garbage-${process.pid}`);
const fs = require('fs');
const assert = require('assert');
Expand Down
2 changes: 1 addition & 1 deletion benchmark/fs/readfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

const path = require('path');
const common = require('../common.js');
const filename = path.resolve(__dirname,
const filename = path.resolve(process.env.NODE_TMPDIR || __dirname,
`.removeme-benchmark-garbage-${process.pid}`);
const fs = require('fs');

Expand Down
2 changes: 1 addition & 1 deletion benchmark/fs/write-stream-throughput.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

const path = require('path');
const common = require('../common.js');
const filename = path.resolve(__dirname,
const filename = path.resolve(process.env.NODE_TMPDIR || __dirname,
`.removeme-benchmark-garbage-${process.pid}`);
const fs = require('fs');

Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-benchmark-fs.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
'use strict';

require('../common');
const common = require('../common');
const runBenchmark = require('../common/benchmark');

runBenchmark('fs', [
'n=1',
'size=1',
'dur=1',
'dur=0.1',
'len=1024',
'concurrent=1',
'pathType=relative',
'statType=fstat',
'statSyncType=fstatSync',
'encodingType=buf',
'filesize=1024'
]);
], { NODE_TMPDIR: common.tmpDir });

0 comments on commit d610fad

Please sign in to comment.