benchmark: make temp file path configurable

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: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Rich Trott 2017-12-21 15:04:24 -08:00 committed by Anatoli Papirovski
parent 4444b6b9ad
commit d610fad390
No known key found for this signature in database
GPG Key ID: 614E2E1ABEB4B2C0
4 changed files with 6 additions and 6 deletions

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -1,12 +1,12 @@
'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',
@ -14,4 +14,4 @@ runBenchmark('fs', [
'statSyncType=fstatSync',
'encodingType=buf',
'filesize=1024'
]);
], { NODE_TMPDIR: common.tmpDir });