-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
test, benchmark: create shared runBenchmark func #15004
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7ab1619
test, benchmark: create shared runBenchmark func
maclover7 a6395a9
[squash] require common + convert forgotten arrays benchmarks
maclover7 ae90f1f
[squash] fix typo
maclover7 4388c22
[squash] rename benchmarks to benchmark
maclover7 3e5e2e2
[squash] add initial documentation
maclover7 b3f4c41
[squash] convert test-benchmark-dns
maclover7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
test, benchmark: create shared runBenchmark func
Mostly shared/duplicated logic between all benchmark test files, so creating a new common module to store it.
- Loading branch information
commit 7ab16191c9b36428d58b1ede1301930c70424f29
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| 'use strict'; | ||
|
|
||
| const assert = require('assert'); | ||
| const fork = require('child_process').fork; | ||
| const path = require('path'); | ||
|
|
||
| const runjs = path.join(__dirname, '..', '..', 'benchmark', 'run.js'); | ||
|
|
||
| function runBenchmark(name, args, env) { | ||
| const argv = []; | ||
|
|
||
| for (let i = 0; i < args.length; i++) { | ||
| argv.push('--set'); | ||
| argv.push(args[i]); | ||
| } | ||
|
|
||
| argv.push(name); | ||
|
|
||
| const mergedEnv = Object.assign({}, process.env, env); | ||
|
|
||
| const child = fork(runjs, argv, { env: mergedEnv }); | ||
| child.on('exit', (code, signal) => { | ||
| assert.strictEqual(code, 0); | ||
| assert.strictEqual(signal, null); | ||
| }); | ||
| } | ||
|
|
||
| module.exports = runBenchmark; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,5 @@ | ||
| 'use strict'; | ||
|
|
||
| require('../common'); | ||
| const runBenchmark = require('../common/benchmarks'); | ||
|
|
||
| // Minimal test for cluster benchmarks. This makes sure the benchmarks aren't | ||
| // horribly broken but nothing more than that. | ||
|
|
||
| const assert = require('assert'); | ||
| const fork = require('child_process').fork; | ||
| const path = require('path'); | ||
|
|
||
| const runjs = path.join(__dirname, '..', '..', 'benchmark', 'run.js'); | ||
| const argv = ['--set', 'n=1', | ||
| '--set', 'payload=string', | ||
| '--set', 'sendsPerBroadcast=1', | ||
| 'cluster']; | ||
|
|
||
| const child = fork(runjs, argv); | ||
| child.on('exit', (code, signal) => { | ||
| assert.strictEqual(code, 0); | ||
| assert.strictEqual(signal, null); | ||
| }); | ||
| runBenchmark('cluster', ['n=1', 'payload=string', 'sendsPerBroadcast=1']); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,5 @@ | ||
| 'use strict'; | ||
|
|
||
| require('../common'); | ||
| const runBenchmark = require('../common/benchmarks'); | ||
|
|
||
| // Minimal test for domain benchmarks. This makes sure the benchmarks aren't | ||
| // horribly broken but nothing more than that. | ||
|
|
||
| const assert = require('assert'); | ||
| const fork = require('child_process').fork; | ||
| const path = require('path'); | ||
|
|
||
| const runjs = path.join(__dirname, '..', '..', 'benchmark', 'run.js'); | ||
| const argv = ['--set', 'arguments=0', | ||
| '--set', 'n=1', | ||
| 'domain']; | ||
|
|
||
| const child = fork(runjs, argv); | ||
| child.on('exit', (code, signal) => { | ||
| assert.strictEqual(code, 0); | ||
| assert.strictEqual(signal, null); | ||
| }); | ||
| runBenchmark('domain', ['n=1', 'arguments=0']); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,5 @@ | ||
| 'use strict'; | ||
|
|
||
| require('../common'); | ||
| const runBenchmark = require('../common/benchmarks'); | ||
|
|
||
| // Minimal test for events benchmarks. This makes sure the benchmarks aren't | ||
| // horribly broken but nothing more than that. | ||
|
|
||
| const assert = require('assert'); | ||
| const fork = require('child_process').fork; | ||
| const path = require('path'); | ||
|
|
||
| const runjs = path.join(__dirname, '..', '..', 'benchmark', 'run.js'); | ||
| const argv = ['--set', 'n=1', | ||
| 'events']; | ||
|
|
||
| const child = fork(runjs, argv); | ||
| child.on('exit', (code, signal) => { | ||
| assert.strictEqual(code, 0); | ||
| assert.strictEqual(signal, null); | ||
| }); | ||
| runBenchmark('events', ['n=1']); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,5 @@ | ||
| 'use strict'; | ||
|
|
||
| require('../common'); | ||
| const runBenchmark = require('../common/benchmarks'); | ||
|
|
||
| // Minimal test for os benchmarks. This makes sure the benchmarks aren't | ||
| // horribly broken but nothing more than that. | ||
|
|
||
| const assert = require('assert'); | ||
| const fork = require('child_process').fork; | ||
| const path = require('path'); | ||
|
|
||
| const runjs = path.join(__dirname, '..', '..', 'benchmark', 'run.js'); | ||
| const argv = ['--set', 'n=1', | ||
| 'os']; | ||
|
|
||
| const child = fork(runjs, argv); | ||
| child.on('exit', (code, signal) => { | ||
| assert.strictEqual(code, 0); | ||
| assert.strictEqual(signal, null); | ||
| }); | ||
| runBenchmark('os', ['n=1']); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,12 @@ | ||
| 'use strict'; | ||
|
|
||
| require('../common'); | ||
|
|
||
| // Minimal test for path benchmarks. This makes sure the benchmarks aren't | ||
| // horribly broken but nothing more than that. | ||
|
|
||
| const assert = require('assert'); | ||
| const fork = require('child_process').fork; | ||
| const path = require('path'); | ||
|
|
||
| const runjs = path.join(__dirname, '..', '..', 'benchmark', 'run.js'); | ||
| const argv = ['--set', 'n=1', | ||
| '--set', 'path=', | ||
| '--set', 'pathext=', | ||
| '--set', 'paths=', | ||
| '--set', 'props=', | ||
| 'path']; | ||
|
|
||
| const child = fork(runjs, argv); | ||
| child.on('exit', (code, signal) => { | ||
| assert.strictEqual(code, 0); | ||
| assert.strictEqual(signal, null); | ||
| }); | ||
| const runBenchmark = require('../common/benchmarks'); | ||
|
|
||
| runBenchmark('path', | ||
| [ | ||
| 'n=1', | ||
| 'path=', | ||
| 'pathext=', | ||
| 'paths=', | ||
| 'props=' | ||
| ]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,10 @@ | ||
| 'use strict'; | ||
|
|
||
| require('../common'); | ||
|
|
||
| // Minimal test for process benchmarks. This makes sure the benchmarks aren't | ||
| // horribly broken but nothing more than that. | ||
|
|
||
| const assert = require('assert'); | ||
| const fork = require('child_process').fork; | ||
| const path = require('path'); | ||
|
|
||
| const runjs = path.join(__dirname, '..', '..', 'benchmark', 'run.js'); | ||
| const argv = ['--set', 'millions=0.000001', | ||
| '--set', 'n=1', | ||
| '--set', 'type=raw', | ||
| 'process']; | ||
|
|
||
| const child = fork(runjs, argv); | ||
| child.on('exit', (code, signal) => { | ||
| assert.strictEqual(code, 0); | ||
| assert.strictEqual(signal, null); | ||
| }); | ||
| const runBenchmark = require('../common/benchmarks'); | ||
|
|
||
| runBenchmark('process', | ||
| [ | ||
| 'millions=0.000001', | ||
| 'n=1', | ||
| 'type=raw' | ||
| ]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,11 @@ | ||
| 'use strict'; | ||
|
|
||
| require('../common'); | ||
|
|
||
| // Minimal test for timers benchmarks. This makes sure the benchmarks aren't | ||
| // horribly broken but nothing more than that. | ||
|
|
||
| const assert = require('assert'); | ||
| const fork = require('child_process').fork; | ||
| const path = require('path'); | ||
|
|
||
| const runjs = path.join(__dirname, '..', '..', 'benchmark', 'run.js'); | ||
| const argv = ['--set', 'type=depth', | ||
| '--set', 'millions=0.000001', | ||
| '--set', 'thousands=0.001', | ||
| 'timers']; | ||
|
|
||
| const env = Object.assign({}, process.env, | ||
| { NODEJS_BENCHMARK_ZERO_ALLOWED: 1 }); | ||
|
|
||
| const child = fork(runjs, argv, { env }); | ||
| child.on('exit', (code, signal) => { | ||
| assert.strictEqual(code, 0); | ||
| assert.strictEqual(signal, null); | ||
| }); | ||
| const runBenchmark = require('../common/benchmarks'); | ||
|
|
||
| runBenchmark('timers', | ||
| [ | ||
| 'type=depth', | ||
| 'millions=0.000001', | ||
| 'thousands=0.001' | ||
| ], | ||
| { NODEJS_BENCHMARK_ZERO_ALLOWED: 1 }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,11 @@ | ||
| 'use strict'; | ||
|
|
||
| require('../common'); | ||
|
|
||
| // Minimal test for zlib benchmarks. This makes sure the benchmarks aren't | ||
| // horribly broken but nothing more than that. | ||
|
|
||
| const assert = require('assert'); | ||
| const fork = require('child_process').fork; | ||
| const path = require('path'); | ||
|
|
||
| const runjs = path.join(__dirname, '..', '..', 'benchmark', 'run.js'); | ||
| const argv = ['--set', 'method=deflate', | ||
| '--set', 'n=1', | ||
| '--set', 'options=true', | ||
| '--set', 'type=Deflate', | ||
| 'zlib']; | ||
|
|
||
| const child = fork(runjs, argv); | ||
| child.on('exit', (code, signal) => { | ||
| assert.strictEqual(code, 0); | ||
| assert.strictEqual(signal, null); | ||
| }); | ||
| const runBenchmark = require('../common/benchmarks'); | ||
|
|
||
| runBenchmark('zlib', | ||
| [ | ||
| 'method=deflate', | ||
| 'n=1', | ||
| 'options=true', | ||
| 'type=Deflate' | ||
| ]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,13 @@ | ||
| 'use strict'; | ||
|
|
||
| require('../common'); | ||
|
|
||
| const assert = require('assert'); | ||
| const fork = require('child_process').fork; | ||
| const path = require('path'); | ||
|
|
||
| const runjs = path.join(__dirname, '..', '..', 'benchmark', 'run.js'); | ||
|
|
||
| const env = Object.assign({}, process.env, | ||
| { NODEJS_BENCHMARK_ZERO_ALLOWED: 1 }); | ||
|
|
||
| const child = fork( | ||
| runjs, | ||
| [ | ||
| '--set', 'dur=0', | ||
| '--set', 'n=1', | ||
| '--set', 'len=1', | ||
| '--set', 'params=1', | ||
| '--set', 'methodName=execSync', | ||
| 'child_process' | ||
| ], | ||
| { env } | ||
| ); | ||
|
|
||
| child.on('exit', (code, signal) => { | ||
| assert.strictEqual(code, 0); | ||
| assert.strictEqual(signal, null); | ||
| }); | ||
| const runBenchmark = require('../common/benchmarks'); | ||
|
|
||
| runBenchmark('child_process', | ||
| [ | ||
| 'dur=0', | ||
| 'n=1', | ||
| 'len=1', | ||
| 'params=1', | ||
| 'methodName=execSync', | ||
| ], | ||
| { NODEJS_BENCHMARK_ZERO_ALLOWED: 1 }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this will need a
/* eslint-disable required-modules */at the top to pass linting.Please run
make lintto make sure :-)