ifneq ($(strip $(findstring check,$(MAKECMDGOALS)) \
$(findstring test,$(MAKECMDGOALS)) \
+ $(findstring perf,$(MAKECMDGOALS)) \
$(findstring tidy,$(MAKECMDGOALS))),)
CFG_INFO := $(info cfg: including test rules)
include $(CFG_SRC_DIR)/mk/tests.mk
endif
+ifneq ($(findstring perf,$(MAKECMDGOALS)),)
+ CFG_INFO := $(info cfg: including perf rules)
+ include $(CFG_SRC_DIR)/mk/perf.mk
+endif
+
ifneq ($(findstring clean,$(MAKECMDGOALS)),)
CFG_INFO := $(info cfg: including clean rules)
include $(CFG_SRC_DIR)/mk/clean.mk
rustllvm \
dl stage0 stage1 stage2 stage3 \
stage0/lib stage1/lib stage2/lib stage3/lib \
- test/run-pass test/run-fail test/compile-fail test/bench test/pretty
+ test/run-pass test/run-fail test/compile-fail \
+ test/bench test/perf test/pretty
do
make_dir $i
done
probe CFG_GCC gcc
probe CFG_LLVM_CONFIG llvm-config
probe CFG_VALGRIND valgrind
+probe CFG_PERF perf
probe CFG_MAKEINFO makeinfo
probe CFG_TEXI2PDF texi2pdf
probe CFG_TEX tex
CFG_UNIXY := 1
CFG_LDENV := LD_LIBRARY_PATH
CFG_DEF_SUFFIX := .linux.def
+ ifdef CFG_PERF
+ CFG_PERF_TOOL :=\
+ $(CFG_PERF) \
+ stat \
+ -e cycles \
+ -e instructions \
+ -e cache-references \
+ -e cache-misses \
+ -e branches \
+ -e branch-misses \
+ -e bus-cycles \
+ -e task-clock \
+ -e page-faults \
+ -e context-switches \
+ -e cpu-migrations \
+ -e kmem:mm_page_alloc \
+ -e syscalls:sys_enter \
+ -e sched:sched_switch \
+ -e fs:do_sys_open \
+ -i \
+ -r 10
+ else
+ ifdef CFG_VALGRIND
+ CFG_PERF_TOOL :=\
+ $(CFG_VALGRIND) --tool=cachegrind --cache-sim=yes --branch-sim=yes
+ else
+ CFG_PERF_TOOL := /usr/bin/time --verbose
+ endif
+ endif
endif
ifeq ($(CFG_OSTYPE), Darwin)
BENCH_RS := $(wildcard $(S)src/test/bench/*.rs)
PRETTY_RS := $(wildcard $(S)src/test/pretty/*.rs)
+# perf tests are the same as bench tests only they run under
+# a performance monitor.
+PERF_RS := $(wildcard $(S)src/test/bench/*.rs)
+
RPASS_TESTS := $(RPASS_RC) $(RPASS_RS)
RFAIL_TESTS := $(RFAIL_RC) $(RFAIL_RS)
CFAIL_TESTS := $(CFAIL_RC) $(CFAIL_RS)
BENCH_TESTS := $(BENCH_RS)
+PERF_TESTS := $(PERF_RS)
PRETTY_TESTS := $(PRETTY_RS)
FT := run_pass_stage2
CTEST_RUNTOOL = --runtool "$(CFG_VALGRIND)"
endif
+# Arguments to the perf tests
+ifdef CFG_PERF_TOOL
+ CTEST_PERF_RUNTOOL = --runtool "$(CFG_PERF_TOOL)"
+endif
+
CTEST_TESTARGS := $(TESTARGS)
ifdef VERBOSE
$$(Q)touch $$@
-# Rules for the cfail/rfail/rpass/bench test runner
+# Rules for the cfail/rfail/rpass/bench/perf test runner
check-stage$(2)-cfail: test/compile-fail.stage$(2).out \
check-stage$(2)-bench: test/bench.stage$(2).out \
+check-stage$(2)-perf: test/perf.stage$(2).out \
+
check-stage$(2)-pretty-rpass: test/pretty-rpass.stage$(2).out \
check-stage$(2)-pretty-rfail: test/pretty-rfail.stage$(2).out \
--mode run-pass \
$$(CTEST_RUNTOOL) \
+PERF_ARGS$(2) := $$(CTEST_COMMON_ARGS$(2)) \
+ --src-base $(S)src/test/bench/ \
+ --build-base test/perf/ \
+ --mode run-pass \
+ $$(CTEST_PERF_RUNTOOL) \
+
PRETTY_RPASS_ARGS$(2) := $$(CTEST_COMMON_ARGS$(2)) \
--src-base $$(S)src/test/run-pass/ \
--build-base test/run-pass/ \
$$(Q)$$(call CFG_RUN_CTEST,$(2),$$<) $$(BENCH_ARGS$(2))
$$(Q)touch $$@
+test/perf.stage$(2).out.tmp: test/compiletest.stage$(2)$$(X) \
+ $$(BENCH_TESTS)
+ @$$(call E, perf: $$<)
+ $$(Q)$$(call CFG_RUN_CTEST,$(2),$$<) $$(PERF_ARGS$(2))
+ $$(Q)touch $$@
+
test/pretty-rpass.stage$(2).out.tmp: test/compiletest.stage$(2)$$(X) \
$$(RPASS_TESTS)
@$$(call E, run: $$<)