Skip to content

Commit 0376b5b

Browse files
joaocgreisTrott
authored andcommitted
benchmark: use test/common/tmpdir consistently
Many benchmarks use test/common/tmpdir. This changes 3 benchmarks that use NODE_TMPDIR to also use test/common/tmpdir. This is necessary in preparation for the next commit that changes tmpdir to delete tmpdir.path when the Node.js process exits. Thus, if multiple benchmarks are run sequentially, the ones that use tmpdir will remove the directory and the ones changed here would fail because it does not exist. This happens when running test/benchmark. Note: to explicitly select a directory for tmpdir, use NODE_TEST_DIR. PR-URL: #28858 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 3eea43a commit 0376b5b

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

benchmark/fs/read-stream-throughput.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33

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

9+
const tmpdir = require('../../test/common/tmpdir');
10+
tmpdir.refresh();
11+
const filename = path.resolve(tmpdir.path,
12+
`.removeme-benchmark-garbage-${process.pid}`);
13+
1114
let encodingType, encoding, size, filesize;
1215

1316
const bench = common.createBenchmark(main, {

benchmark/fs/readfile.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55

66
const path = require('path');
77
const common = require('../common.js');
8-
const filename = path.resolve(process.env.NODE_TMPDIR || __dirname,
9-
`.removeme-benchmark-garbage-${process.pid}`);
108
const fs = require('fs');
119
const assert = require('assert');
1210

11+
const tmpdir = require('../../test/common/tmpdir');
12+
tmpdir.refresh();
13+
const filename = path.resolve(tmpdir.path,
14+
`.removeme-benchmark-garbage-${process.pid}`);
15+
1316
const bench = common.createBenchmark(main, {
1417
dur: [5],
1518
len: [1024, 16 * 1024 * 1024],

benchmark/fs/write-stream-throughput.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33

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

8+
const tmpdir = require('../../test/common/tmpdir');
9+
tmpdir.refresh();
10+
const filename = path.resolve(tmpdir.path,
11+
`.removeme-benchmark-garbage-${process.pid}`);
12+
1013
const bench = common.createBenchmark(main, {
1114
dur: [5],
1215
encodingType: ['buf', 'asc', 'utf'],

test/benchmark/test-benchmark-fs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ runBenchmark('fs', [
1919
'filesize=1024',
2020
'dir=.github',
2121
'withFileTypes=false'
22-
], { NODE_TMPDIR: tmpdir.path, NODEJS_BENCHMARK_ZERO_ALLOWED: 1 });
22+
], { NODEJS_BENCHMARK_ZERO_ALLOWED: 1 });

0 commit comments

Comments
 (0)