From 14eb97ebf7e9dceb852a985a69971bd02fc3f53e Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 21 Dec 2017 15:04:24 -0800 Subject: [PATCH] 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 Reviewed-By: Jon Moss Reviewed-By: Richard Lau Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Gibson Fahnestock --- benchmark/fs/read-stream-throughput.js | 2 +- benchmark/fs/readfile.js | 2 +- benchmark/fs/write-stream-throughput.js | 2 +- test/parallel/test-benchmark-fs.js | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/benchmark/fs/read-stream-throughput.js b/benchmark/fs/read-stream-throughput.js index 162cef6864a686..e0dc7edc05ea3e 100644 --- a/benchmark/fs/read-stream-throughput.js +++ b/benchmark/fs/read-stream-throughput.js @@ -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'); diff --git a/benchmark/fs/readfile.js b/benchmark/fs/readfile.js index 82479ff14e5f68..7c55073fe0f017 100644 --- a/benchmark/fs/readfile.js +++ b/benchmark/fs/readfile.js @@ -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'); diff --git a/benchmark/fs/write-stream-throughput.js b/benchmark/fs/write-stream-throughput.js index 5c6464fdbb2cbb..c61b5900111411 100644 --- a/benchmark/fs/write-stream-throughput.js +++ b/benchmark/fs/write-stream-throughput.js @@ -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'); diff --git a/test/parallel/test-benchmark-fs.js b/test/parallel/test-benchmark-fs.js index eeac59fdab06ac..415eb1896b69a8 100644 --- a/test/parallel/test-benchmark-fs.js +++ b/test/parallel/test-benchmark-fs.js @@ -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 });