Skip to content

Commit

Permalink
benchmark: use test/common/tmpdir consistently
Browse files Browse the repository at this point in the history
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 <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
joaocgreis authored and Trott committed Aug 11, 2019
1 parent 3eea43a commit 0376b5b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
7 changes: 5 additions & 2 deletions benchmark/fs/read-stream-throughput.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@

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

const tmpdir = require('../../test/common/tmpdir');
tmpdir.refresh();
const filename = path.resolve(tmpdir.path,
`.removeme-benchmark-garbage-${process.pid}`);

let encodingType, encoding, size, filesize;

const bench = common.createBenchmark(main, {
Expand Down
7 changes: 5 additions & 2 deletions benchmark/fs/readfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@

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

const tmpdir = require('../../test/common/tmpdir');
tmpdir.refresh();
const filename = path.resolve(tmpdir.path,
`.removeme-benchmark-garbage-${process.pid}`);

const bench = common.createBenchmark(main, {
dur: [5],
len: [1024, 16 * 1024 * 1024],
Expand Down
7 changes: 5 additions & 2 deletions benchmark/fs/write-stream-throughput.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@

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

const tmpdir = require('../../test/common/tmpdir');
tmpdir.refresh();
const filename = path.resolve(tmpdir.path,
`.removeme-benchmark-garbage-${process.pid}`);

const bench = common.createBenchmark(main, {
dur: [5],
encodingType: ['buf', 'asc', 'utf'],
Expand Down
2 changes: 1 addition & 1 deletion test/benchmark/test-benchmark-fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ runBenchmark('fs', [
'filesize=1024',
'dir=.github',
'withFileTypes=false'
], { NODE_TMPDIR: tmpdir.path, NODEJS_BENCHMARK_ZERO_ALLOWED: 1 });
], { NODEJS_BENCHMARK_ZERO_ALLOWED: 1 });

0 comments on commit 0376b5b

Please sign in to comment.