Skip to content

Commit 14eb97e

Browse files
TrottMylesBorins
authored andcommitted
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: #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]>
1 parent 2d11f6b commit 14eb97e

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

benchmark/fs/read-stream-throughput.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
const path = require('path');
55
const common = require('../common.js');
6-
const filename = path.resolve(__dirname,
6+
const filename = path.resolve(process.env.NODE_TMPDIR || __dirname,
77
`.removeme-benchmark-garbage-${process.pid}`);
88
const fs = require('fs');
99
const assert = require('assert');

benchmark/fs/readfile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

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

benchmark/fs/write-stream-throughput.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

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

test/parallel/test-benchmark-fs.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
'use strict';
22

3-
require('../common');
3+
const common = require('../common');
44
const runBenchmark = require('../common/benchmark');
55

66
runBenchmark('fs', [
77
'n=1',
88
'size=1',
9-
'dur=1',
9+
'dur=0.1',
1010
'len=1024',
1111
'concurrent=1',
1212
'pathType=relative',
1313
'statType=fstat',
1414
'statSyncType=fstatSync',
1515
'encodingType=buf',
1616
'filesize=1024'
17-
]);
17+
], { NODE_TMPDIR: common.tmpDir });

0 commit comments

Comments
 (0)