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: have benchmark tests confirm that only one line of output is generated per benchmark file #21046

Closed
wants to merge 3 commits 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
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,13 @@ test-valgrind: all
test-check-deopts: all
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) --check-deopts parallel sequential

benchmark/misc/function_call/build/Release/binding.node: all \
benchmark/misc/function_call/napi_binding.c \
benchmark/misc/function_call/binding.cc \
benchmark/misc/function_call/binding.gyp
benchmark/napi/function_call/build/Release/binding.node: all \
benchmark/napi/function_call/napi_binding.c \
benchmark/napi/function_call/binding.cc \
benchmark/napi/function_call/binding.gyp
$(NODE) deps/npm/node_modules/node-gyp/bin/node-gyp rebuild \
--python="$(PYTHON)" \
--directory="$(shell pwd)/benchmark/misc/function_call" \
--directory="$(shell pwd)/benchmark/napi/function_call" \
--nodedir="$(shell pwd)"

# Implicitly depends on $(NODE_EXE). We don't depend on it explicitly because
Expand Down Expand Up @@ -1115,7 +1115,7 @@ LINT_CPP_EXCLUDE += $(wildcard test/addons-napi/??_*/*.cc test/addons-napi/??_*/
LINT_CPP_EXCLUDE += src/tracing/trace_event.h src/tracing/trace_event_common.h

LINT_CPP_FILES = $(filter-out $(LINT_CPP_EXCLUDE), $(wildcard \
benchmark/misc/function_call/binding.cc \
benchmark/napi/function_call/binding.cc \
src/*.c \
src/*.cc \
src/*.h \
Expand Down
4 changes: 4 additions & 0 deletions benchmark/misc/util-extend-vs-object-assign.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ const bench = common.createBenchmark(main, {
});

function main({ n, type }) {
// Default value for tests.
if (type === '')
type = 'extend';

let fn;
if (type === 'extend') {
fn = util._extend;
Expand Down
19 changes: 18 additions & 1 deletion test/common/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,27 @@ function runBenchmark(name, args, env) {

const mergedEnv = Object.assign({}, process.env, env);

const child = fork(runjs, argv, { env: mergedEnv });
const child = fork(runjs, argv, { env: mergedEnv, stdio: 'pipe' });
child.stdout.setEncoding('utf8');

let stdout = '';
child.stdout.on('data', (line) => {
stdout += line;
});

child.on('exit', (code, signal) => {
assert.strictEqual(code, 0);
assert.strictEqual(signal, null);
// This bit makes sure that each benchmark file is being sent settings such
// that the benchmark file runs just one set of options. This helps keep the
// benchmark tests from taking a long time to run. Therefore, each benchmark
// file should result in three lines of output: a blank line, a line with
// the name of the benchmark file, and a line with the only results that we
// get from testing the benchmark file.
assert.ok(
/^(?:\n.+?\n.+?\n)+$/.test(stdout),
`benchmark file not running exactly one configuration in test: ${stdout}`
);
});
}

Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-benchmark-misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ runBenchmark('misc', [
'dur=0.1',
'method=',
'n=1',
'type=extend',
'val=magyarország.icom.museum'
'type=',
'val=magyarország.icom.museum',
], { NODEJS_BENCHMARK_ZERO_ALLOWED: 1 });