Skip to content

Commit ffa6be6

Browse files
committed
build: add make recipes for running random JS + C examples plus benchmarks
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 4dc4f6c commit ffa6be6

File tree

4 files changed

+97
-0
lines changed

4 files changed

+97
-0
lines changed

tools/make/common.mk

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ else
4747
endif
4848
endif
4949

50+
# Indicate whether to build native add-ons:
51+
ifndef BUILD_ADDONS
52+
BUILD_NATIVE_ADDONS := false
53+
else
54+
ifeq ($(BUILD_ADDONS), 1)
55+
BUILD_NATIVE_ADDONS := true
56+
else
57+
BUILD_NATIVE_ADDONS := false
58+
endif
59+
endif
60+
5061
# Indicate whether to fix linting errors:
5162
ifndef FIX
5263
AUTOFIX := false

tools/make/lib/benchmark/c.mk

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,27 @@ benchmark-c-files:
9898
done
9999

100100
.PHONY: benchmark-c-files
101+
102+
#/
103+
# Runs random c benchmarks consecutively.
104+
#
105+
# @param {string} [PACKAGES_PATTERN='package.json'] - filename pattern for identifying packages
106+
# @param {string} [PACKAGES_FILTER='.*/.*'] - filepath pattern for finding packages
107+
# @param {string} [RANDOM_SELECTION_SIZE=100] - number of packages
108+
#
109+
# @example
110+
# make benchmark-random-c
111+
#
112+
# @example
113+
# make benchmark-random-c RANDOM_SELECTION_SIZE=10
114+
#/
115+
benchmark-random-c: $(NODE_MODULES)
116+
$(QUIET) make -s list-random-lib-pkgs PACKAGES_PATTERN='binding.gyp' | while read -r pkg; do \
117+
echo ""; \
118+
echo "Running benchmark: $$pkg"; \
119+
NODE_ENV="$(NODE_ENV_BENCHMARK)" \
120+
NODE_PATH="$(NODE_PATH_BENCHMARK)" \
121+
make benchmark-c BENCHMARKS_FILTER="$$pkg/.*" || exit 1; \
122+
done
123+
124+
.PHONY: benchmark-random-c

tools/make/lib/benchmark/javascript.mk

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,40 @@ benchmark-javascript-files: $(NODE_MODULES)
7070
done
7171

7272
.PHONY: benchmark-javascript-files
73+
74+
#/
75+
# Runs random JavaScript benchmarks consecutively.
76+
#
77+
# @param {string} [PACKAGES_PATTERN='package.json'] - filename pattern for identifying packages
78+
# @param {string} [PACKAGES_FILTER='.*/.*'] - filepath pattern for finding packages
79+
# @param {string} [RANDOM_SELECTION_SIZE=100] - number of packages
80+
# @param {*} [BUILD_ADDONS] - flag indicating whether to build native add-ons
81+
#
82+
# @example
83+
# make benchmark-random-javascript
84+
#
85+
# @example
86+
# make benchmark-random-javascript RANDOM_SELECTION_SIZE=10
87+
#/
88+
benchmark-random-javascript: $(NODE_MODULES)
89+
ifeq ($(BUILD_NATIVE_ADDONS), true)
90+
$(QUIET) make -s list-random-lib-pkgs | while read -r pkg; do \
91+
echo ""; \
92+
echo "Running benchmark: $$pkg"; \
93+
pattern=$$(echo "$$pkg" | sed -n -e 's/^.*\(@stdlib\)/\1/p') \
94+
NODE_ADDONS_PATTERN="$$pattern" make install-node-addons; \
95+
NODE_ENV="$(NODE_ENV_BENCHMARK)" \
96+
NODE_PATH="$(NODE_PATH_BENCHMARK)" \
97+
make benchmark-javascript BENCHMARKS_FILTER="$$pkg/.*" || exit 1; \
98+
done
99+
else
100+
$(QUIET) make -s list-random-lib-pkgs | while read -r pkg; do \
101+
echo ""; \
102+
echo "Running benchmark: $$pkg"; \
103+
NODE_ENV="$(NODE_ENV_BENCHMARK)" \
104+
NODE_PATH="$(NODE_PATH_BENCHMARK)" \
105+
make benchmark-javascript BENCHMARKS_FILTER="$$pkg/.*" || exit 1; \
106+
done
107+
endif
108+
109+
.PHONY: benchmark-random-javascript

tools/make/lib/examples/c.mk

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,28 @@ examples-c-files:
9898
done
9999

100100
.PHONY: example-c-files
101+
102+
#/
103+
# Runs random C examples consecutively.
104+
#
105+
# @param {string} [PACKAGES_PATTERN='package.json'] - filename pattern for identifying packages
106+
# @param {string} [PACKAGES_FILTER='.*/.*'] - filepath pattern for finding packages
107+
# @param {string} [RANDOM_SELECTION_SIZE=100] - number of packages
108+
#
109+
# @example
110+
# make examples-random-c
111+
#
112+
# @example
113+
# make examples-random-c RANDOM_SELECTION_SIZE=10
114+
#/
115+
examples-random-c: $(NODE_MODULES)
116+
$(QUIET) make -s list-random-lib-pkgs PACKAGES_PATTERN='binding.gyp' | while read -r pkg; do \
117+
echo ""; \
118+
echo "Running example: $$pkg"; \
119+
NODE_ENV="$(NODE_ENV_EXAMPLES)" \
120+
NODE_PATH="$(NODE_PATH_EXAMPLES)" \
121+
make examples-c EXAMPLES_FILTER="$$pkg/.*" || exit 1; \
122+
done
123+
124+
.PHONY: examples-random-c
125+

0 commit comments

Comments
 (0)