Skip to content
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

test,benchmark: enable minimal CI for http bench #12025

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions benchmark/http/chunked.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ var common = require('../common.js');
var bench = common.createBenchmark(main, {
num: [1, 4, 8, 16],
size: [1, 64, 256],
c: [100]
c: [100],
dur: [10]
});

function main(conf) {
Expand All @@ -33,7 +34,8 @@ function main(conf) {

server.listen(common.PORT, function() {
bench.http({
connections: conf.c
connections: conf.c,
duration: conf.dur
}, function() {
server.close();
});
Expand Down
6 changes: 4 additions & 2 deletions benchmark/http/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ if (cluster.isMaster) {
// unicode confuses ab on os x.
type: ['bytes', 'buffer'],
length: [4, 1024, 102400],
c: [50, 500]
c: [50, 500],
dur: [10]
});
} else {
require('./_http_simple.js');
Expand All @@ -30,7 +31,8 @@ function main(conf) {

bench.http({
path: path,
connections: conf.c
connections: conf.c,
duration: conf.dur
}, function() {
w1.destroy();
w2.destroy();
Expand Down
6 changes: 4 additions & 2 deletions benchmark/http/end-vs-write-end.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ var bench = common.createBenchmark(main, {
type: ['asc', 'utf', 'buf'],
kb: [64, 128, 256, 1024],
c: [100],
method: ['write', 'end']
method: ['write', 'end'],
dur: [10]
});

function main(conf) {
Expand Down Expand Up @@ -50,7 +51,8 @@ function main(conf) {

server.listen(common.PORT, function() {
bench.http({
connections: conf.c
connections: conf.c,
duration: conf.dur
}, function() {
server.close();
});
Expand Down
6 changes: 4 additions & 2 deletions benchmark/http/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ var bench = common.createBenchmark(main, {
length: [4, 1024, 102400],
chunks: [0, 1, 4], // chunks=0 means 'no chunked encoding'.
c: [50, 500],
res: ['normal', 'setHeader', 'setHeaderWH']
res: ['normal', 'setHeader', 'setHeaderWH'],
dur: [10]
});

function main(conf) {
Expand All @@ -20,7 +21,8 @@ function main(conf) {

bench.http({
path: path,
connections: conf.c
connections: conf.c,
duration: conf.dur
}, function() {
server.close();
});
Expand Down
41 changes: 41 additions & 0 deletions test/sequential/test-benchmark-http.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
'use strict';

require('../common');

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

// Because some 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');

// Q: 😱 WHY SO MANY OPTIONS??!! 😱
// A: `wrk` will not accept a duration shorter than 1 second, so all benchmarks
// that depend on `wrk` will run for as many seconds as they have
// combinations of options. By specifying just one option for `res` and
// `method` and so on, we make sure those benchmark files run, but only for
// a little more than one second each.
const child = fork(runjs,
['--set', 'n=1',
'--set', 'c=8',
'--set', 'dur=1',
'--set', 'size=1',
'--set', 'num=1',
'--set', 'bytes=32',
'--set', 'method=write',
'--set', 'type=asc',
'--set', 'length=4',
'--set', 'kb=64',
'--set', 'res=normal',
'--set', 'chunks=0',
'http']);
child.on('exit', (code, signal) => {
assert.strictEqual(code, 0);
assert.strictEqual(signal, null);
});