Skip to content

Commit

Permalink
test: add test-benchmark-napi
Browse files Browse the repository at this point in the history
Also makes sure that the napi benchmark is built before running jstest.

Skipped on windows since n-api benchmarks aren't built there yet.

PR-URL: #23585
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
  • Loading branch information
forivall authored and MylesBorins committed Nov 26, 2018
1 parent 1484eeb commit 9e9bb85
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ v8:
tools/make-v8.sh $(V8_ARCH).$(BUILDTYPE_LOWER) $(V8_BUILD_OPTIONS)

.PHONY: jstest
jstest: build-addons build-addons-napi ## Runs addon tests and JS tests
jstest: build-addons build-addons-napi bench-addons-build ## Runs addon tests and JS tests
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) \
--skip-tests=$(CI_SKIP_TESTS) \
$(CI_JS_SUITES) \
Expand Down Expand Up @@ -414,7 +414,7 @@ clear-stalled:
echo $${PS_OUT} | xargs kill -9; \
fi

test-build: | all build-addons build-addons-napi
test-build: | all build-addons build-addons-napi bench-addons-build

test-build-addons-napi: all build-addons-napi

Expand Down Expand Up @@ -444,7 +444,7 @@ test-ci-native: | test/addons/.buildstamp test/addons-napi/.buildstamp
test-ci-js: | clear-stalled
$(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \
--mode=$(BUILDTYPE_LOWER) --flaky-tests=$(FLAKY_TESTS) \
$(TEST_CI_ARGS) $(CI_JS_SUITES)
$(TEST_CI_ARGS) $(CI_JS_SUITES) --skip-tests=sequential/test-benchmark-napi
@echo "Clean up any leftover processes, error if found."
ps awwx | grep Release/node | grep -v grep | cat
@PS_OUT=`ps awwx | grep Release/node | grep -v grep | awk '{print $$1}'`; \
Expand All @@ -455,7 +455,7 @@ test-ci-js: | clear-stalled
.PHONY: test-ci
# Related CI jobs: most CI tests, excluding node-test-commit-arm-fanned
test-ci: LOGLEVEL := info
test-ci: | clear-stalled build-addons build-addons-napi doc-only
test-ci: | clear-stalled build-addons build-addons-napi doc-only bench-addons-build
out/Release/cctest --gtest_output=tap:cctest.tap
$(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \
--mode=$(BUILDTYPE_LOWER) --flaky-tests=$(FLAKY_TESTS) \
Expand Down Expand Up @@ -496,7 +496,7 @@ test-debug: test-build
test-message: test-build
$(PYTHON) tools/test.py $(PARALLEL_ARGS) message

test-simple: | cctest # Depends on 'all'.
test-simple: | cctest bench-addons-build # Depends on 'all'.
$(PYTHON) tools/test.py $(PARALLEL_ARGS) parallel sequential

test-pummel: all
Expand Down
6 changes: 4 additions & 2 deletions benchmark/napi/function_args/napi_binding.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ static napi_value CallWithArray(napi_env env, napi_callback_info info) {
status = napi_get_array_length(env, array, &length);
assert(status == napi_ok);

for (uint32_t i = 0; i < length; ++i) {
uint32_t i;
for (i = 0; i < length; ++i) {
napi_value v;
status = napi_get_element(env, array, i, &v);
assert(status == napi_ok);
Expand Down Expand Up @@ -173,7 +174,8 @@ static napi_value CallWithArguments(napi_env env, napi_callback_info info) {
status = napi_get_value_uint32(env, args[0], &loop);
assert(status == napi_ok);

for (uint32_t i = 1; i < loop; ++i) {
uint32_t i;
for (i = 1; i < loop; ++i) {
assert(i < argc);
status = napi_typeof(env, args[i], types);
assert(status == napi_ok);
Expand Down
24 changes: 24 additions & 0 deletions test/sequential/test-benchmark-napi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict';

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

if (common.isWindows) {
common.skip('vcbuild.bat doesn\'t build the n-api benchmarks yet');
}

if (!common.isMainThread) {
common.skip('addons are not supported in workers');
}

if (process.features.debug) {
common.skip('benchmark does not work with debug build yet');
}
const runBenchmark = require('../common/benchmark');

runBenchmark('napi',
[
'n=1',
'engine=v8',
'type=String'
],
{ NODEJS_BENCHMARK_ZERO_ALLOWED: 1 });

0 comments on commit 9e9bb85

Please sign in to comment.