Skip to content

Commit

Permalink
test: add http benchmark test
Browse files Browse the repository at this point in the history
  • Loading branch information
joyeecheung committed Apr 8, 2017
1 parent 4303a5e commit 14b27c6
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
8 changes: 4 additions & 4 deletions benchmark/_http-benchmarkers.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ class WrkBenchmarker {
* Simple, single-threaded benchmarker for testing if the benchmark
* works
*/
class DummyBenchmarker {
class TestTroubleBenchmarker {
constructor() {
this.name = 'dummy';
this.executable = path.resolve(__dirname, '_dummy-benchmarker.js');
this.name = 'test-trouble';
this.executable = path.resolve(__dirname, '_test-trouble-benchmarker.js');
this.present = fs.existsSync(this.executable);
}

Expand Down Expand Up @@ -112,7 +112,7 @@ class DummyBenchmarker {
const http_benchmarkers = [
new WrkBenchmarker(),
new AutocannonBenchmarker(),
new DummyBenchmarker()
new TestTroubleBenchmarker()
];

const benchmarkers = {};
Expand Down
File renamed without changes.
34 changes: 34 additions & 0 deletions test/sequential/test-benchmark-http.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use strict';

const common = require('../common');

if (!common.enoughTestMem) {
common.skip('Insufficient memory for HTTP benchmark test');
return;
}

// Minimal test for http benchmarks. This makes sure the benchmarks aren't
// horribly broken but nothing more than that.

// Because the http benchmarks use hardcoded ports, this should be in sequential
// rather than parallel to make sure it does not conflict with tests that choose
// random available ports.

const assert = require('assert');
const fork = require('child_process').fork;
const path = require('path');

const runjs = path.join(__dirname, '..', '..', 'benchmark', 'run.js');

const child = fork(runjs, ['--set', 'dur=0.1',
'--set', 'n=1',
'--set', 'len=1',
'--set', 'c=1',
'--set', 'chunks=0',
'--set', 'benchmarker=test-trouble',
'http'],
{env: {NODEJS_BENCHMARK_ZERO_ALLOWED: 1}});
child.on('exit', (code, signal) => {
assert.strictEqual(code, 0);
assert.strictEqual(signal, null);
});

0 comments on commit 14b27c6

Please sign in to comment.