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 <[email protected]>
Reviewed-By: Jon Moss <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
  • Loading branch information
Trott authored and MylesBorins committed Jan 9, 2018
1 parent 2d11f6b commit 14eb97e
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 14eb97e

Please sign in to comment.