Skip to content

Commit

Permalink
benchmark: use tmpdir.resolve()
Browse files Browse the repository at this point in the history
PR-URL: nodejs#49137
Refs: nodejs#49079
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
  • Loading branch information
LiviaMedeiros authored and alexfernandez committed Nov 1, 2023
1 parent f2903e5 commit 2951b2e
Show file tree
Hide file tree
Showing 14 changed files with 14 additions and 33 deletions.
3 changes: 1 addition & 2 deletions benchmark/esm/cjs-parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ const common = require('../common.js');
const { strictEqual } = require('assert');

const tmpdir = require('../../test/common/tmpdir');
const benchmarkDirectory =
path.resolve(tmpdir.path, 'benchmark-esm-parse');
const benchmarkDirectory = tmpdir.resolve('benchmark-esm-parse');

const bench = common.createBenchmark(main, {
n: [1e2],
Expand Down
3 changes: 1 addition & 2 deletions benchmark/esm/esm-legacyMainResolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ const common = require('../common.js');
const tmpdir = require('../../test/common/tmpdir.js');
const { pathToFileURL } = require('node:url');

const benchmarkDirectory =
path.resolve(tmpdir.path, 'benchmark-import-meta-resolve');
const benchmarkDirectory = tmpdir.resolve('benchmark-import-meta-resolve');

const configs = {
n: [1e4],
Expand Down
3 changes: 1 addition & 2 deletions benchmark/esm/esm-loader-defaultResolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ const common = require('../common.js');
const tmpdir = require('../../test/common/tmpdir.js');
const { pathToFileURL } = require('node:url');

const benchmarkDirectory =
path.resolve(tmpdir.path, 'benchmark-import-meta-resolve');
const benchmarkDirectory = tmpdir.resolve('benchmark-import-meta-resolve');

const parentURL = pathToFileURL(path.join(benchmarkDirectory, 'entry-point.js'));

Expand Down
4 changes: 1 addition & 3 deletions benchmark/fs/read-stream-throughput.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
// Test the throughput of the fs.WriteStream class.
'use strict';

const path = require('path');
const common = require('../common.js');
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 filename = tmpdir.resolve(`.removeme-benchmark-garbage-${process.pid}`);

const bench = common.createBenchmark(main, {
encodingType: ['buf', 'asc', 'utf'],
Expand Down
4 changes: 1 addition & 3 deletions benchmark/fs/readfile-permission-enabled.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
// Then see how many times it got called.
'use strict';

const path = require('path');
const common = require('../common.js');
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 filename = tmpdir.resolve(`.removeme-benchmark-garbage-${process.pid}`);

const bench = common.createBenchmark(main, {
duration: [5],
Expand Down
4 changes: 1 addition & 3 deletions benchmark/fs/readfile-promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
// Yes, this is a silly benchmark. Most benchmarks are silly.
'use strict';

const path = require('path');
const common = require('../common.js');
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 filename = tmpdir.resolve(`.removeme-benchmark-garbage-${process.pid}`);

const bench = common.createBenchmark(main, {
duration: [5],
Expand Down
4 changes: 1 addition & 3 deletions benchmark/fs/readfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
// Yes, this is a silly benchmark. Most benchmarks are silly.
'use strict';

const path = require('path');
const common = require('../common.js');
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 filename = tmpdir.resolve(`.removeme-benchmark-garbage-${process.pid}`);

const bench = common.createBenchmark(main, {
duration: [5],
Expand Down
4 changes: 1 addition & 3 deletions benchmark/fs/write-stream-throughput.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
// Test the throughput of the fs.WriteStream class.
'use strict';

const path = require('path');
const common = require('../common.js');
const fs = require('fs');

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

const bench = common.createBenchmark(main, {
dur: [5],
Expand Down
4 changes: 1 addition & 3 deletions benchmark/fs/writefile-promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
// Yes, this is a silly benchmark. Most benchmarks are silly.
'use strict';

const path = require('path');
const common = require('../common.js');
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 filename = tmpdir.resolve(`.removeme-benchmark-garbage-${process.pid}`);
let filesWritten = 0;
const bench = common.createBenchmark(main, {
duration: [5],
Expand Down
3 changes: 1 addition & 2 deletions benchmark/module/module-loader-circular.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ const path = require('path');
const common = require('../common.js');

const tmpdir = require('../../test/common/tmpdir');
const benchmarkDirectory =
path.resolve(tmpdir.path, 'benchmark-module-circular');
const benchmarkDirectory = tmpdir.resolve('benchmark-module-circular');

const bench = common.createBenchmark(main, {
n: [1e4],
Expand Down
3 changes: 1 addition & 2 deletions benchmark/module/module-loader-deep.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
'use strict';
const fs = require('fs');
const path = require('path');
const common = require('../common.js');

const tmpdir = require('../../test/common/tmpdir');
const benchmarkDirectory = path.join(tmpdir.path, 'nodejs-benchmark-module');
const benchmarkDirectory = tmpdir.resolve('nodejs-benchmark-module');

const bench = common.createBenchmark(main, {
ext: ['', '.js'],
Expand Down
2 changes: 1 addition & 1 deletion benchmark/module/module-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { builtinModules } = require('module');
const common = require('../common.js');

const tmpdir = require('../../test/common/tmpdir');
let benchmarkDirectory = path.join(tmpdir.path, 'nodejs-benchmark-module');
let benchmarkDirectory = tmpdir.resolve('nodejs-benchmark-module');

// Filter all irregular modules.
const otherModules = builtinModules.filter((name) => !/\/|^_|^sys/.test(name));
Expand Down
3 changes: 1 addition & 2 deletions benchmark/module/module-require.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
'use strict';

const fs = require('fs');
const path = require('path');
const common = require('../common.js');
const tmpdir = require('../../test/common/tmpdir');
const benchmarkDirectory = path.join(tmpdir.path, 'nodejs-benchmark-module');
const benchmarkDirectory = tmpdir.resolve('nodejs-benchmark-module');

const bench = common.createBenchmark(main, {
type: ['.js', '.json', 'dir'],
Expand Down
3 changes: 1 addition & 2 deletions benchmark/process/coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ const common = require('../common.js');
const bench = common.createBenchmark(main, {
n: [1e5],
});
const path = require('path');
const { rmSync } = require('fs');
const { spawnSync } = require('child_process');
const tmpdir = require('../../test/common/tmpdir');

const coverageDir = path.join(tmpdir.path, `./cov-${Date.now()}`);
const coverageDir = tmpdir.resolve(`cov-${Date.now()}`);

function main({ n }) {
bench.start();
Expand Down

0 comments on commit 2951b2e

Please sign in to comment.