Add build-system mechanisms for running benchmarks under 'perf'.

This commit is contained in:
Graydon Hoare 2011-09-13 15:06:21 -07:00
parent c84b8e90b8
commit d5b2d62b20
5 changed files with 64 additions and 2 deletions

View File

@ -271,11 +271,17 @@ endif
ifneq ($(strip $(findstring check,$(MAKECMDGOALS)) \ ifneq ($(strip $(findstring check,$(MAKECMDGOALS)) \
$(findstring test,$(MAKECMDGOALS)) \ $(findstring test,$(MAKECMDGOALS)) \
$(findstring perf,$(MAKECMDGOALS)) \
$(findstring tidy,$(MAKECMDGOALS))),) $(findstring tidy,$(MAKECMDGOALS))),)
CFG_INFO := $(info cfg: including test rules) CFG_INFO := $(info cfg: including test rules)
include $(CFG_SRC_DIR)/mk/tests.mk include $(CFG_SRC_DIR)/mk/tests.mk
endif endif
ifneq ($(findstring perf,$(MAKECMDGOALS)),)
CFG_INFO := $(info cfg: including perf rules)
include $(CFG_SRC_DIR)/mk/perf.mk
endif
ifneq ($(findstring clean,$(MAKECMDGOALS)),) ifneq ($(findstring clean,$(MAKECMDGOALS)),)
CFG_INFO := $(info cfg: including clean rules) CFG_INFO := $(info cfg: including clean rules)
include $(CFG_SRC_DIR)/mk/clean.mk include $(CFG_SRC_DIR)/mk/clean.mk

4
configure vendored
View File

@ -183,7 +183,8 @@ for i in \
rustllvm \ rustllvm \
dl stage0 stage1 stage2 stage3 \ dl stage0 stage1 stage2 stage3 \
stage0/lib stage1/lib stage2/lib stage3/lib \ 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 do
make_dir $i make_dir $i
done done
@ -205,6 +206,7 @@ probe CFG_CLANG clang++
probe CFG_GCC gcc probe CFG_GCC gcc
probe CFG_LLVM_CONFIG llvm-config probe CFG_LLVM_CONFIG llvm-config
probe CFG_VALGRIND valgrind probe CFG_VALGRIND valgrind
probe CFG_PERF perf
probe CFG_MAKEINFO makeinfo probe CFG_MAKEINFO makeinfo
probe CFG_TEXI2PDF texi2pdf probe CFG_TEXI2PDF texi2pdf
probe CFG_TEX tex probe CFG_TEX tex

1
mk/perf.mk Normal file
View File

@ -0,0 +1 @@
perf: check-stage2-perf

View File

@ -34,6 +34,35 @@ ifeq ($(CFG_OSTYPE), Linux)
CFG_UNIXY := 1 CFG_UNIXY := 1
CFG_LDENV := LD_LIBRARY_PATH CFG_LDENV := LD_LIBRARY_PATH
CFG_DEF_SUFFIX := .linux.def 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 endif
ifeq ($(CFG_OSTYPE), Darwin) ifeq ($(CFG_OSTYPE), Darwin)

View File

@ -15,10 +15,15 @@ CFAIL_RS := $(wildcard $(S)src/test/compile-fail/*.rs)
BENCH_RS := $(wildcard $(S)src/test/bench/*.rs) BENCH_RS := $(wildcard $(S)src/test/bench/*.rs)
PRETTY_RS := $(wildcard $(S)src/test/pretty/*.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) RPASS_TESTS := $(RPASS_RC) $(RPASS_RS)
RFAIL_TESTS := $(RFAIL_RC) $(RFAIL_RS) RFAIL_TESTS := $(RFAIL_RC) $(RFAIL_RS)
CFAIL_TESTS := $(CFAIL_RC) $(CFAIL_RS) CFAIL_TESTS := $(CFAIL_RC) $(CFAIL_RS)
BENCH_TESTS := $(BENCH_RS) BENCH_TESTS := $(BENCH_RS)
PERF_TESTS := $(PERF_RS)
PRETTY_TESTS := $(PRETTY_RS) PRETTY_TESTS := $(PRETTY_RS)
FT := run_pass_stage2 FT := run_pass_stage2
@ -40,6 +45,11 @@ ifdef CFG_VALGRIND
CTEST_RUNTOOL = --runtool "$(CFG_VALGRIND)" CTEST_RUNTOOL = --runtool "$(CFG_VALGRIND)"
endif endif
# Arguments to the perf tests
ifdef CFG_PERF_TOOL
CTEST_PERF_RUNTOOL = --runtool "$(CFG_PERF_TOOL)"
endif
CTEST_TESTARGS := $(TESTARGS) CTEST_TESTARGS := $(TESTARGS)
ifdef VERBOSE ifdef VERBOSE
@ -150,7 +160,7 @@ test/rustctest.stage$(2).out.tmp: test/rustctest.stage$(2)$$(X)
$$(Q)touch $$@ $$(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)-cfail: test/compile-fail.stage$(2).out \
@ -160,6 +170,8 @@ check-stage$(2)-rpass: test/run-pass.stage$(2).out \
check-stage$(2)-bench: test/bench.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-rpass: test/pretty-rpass.stage$(2).out \
check-stage$(2)-pretty-rfail: test/pretty-rfail.stage$(2).out \ check-stage$(2)-pretty-rfail: test/pretty-rfail.stage$(2).out \
@ -203,6 +215,12 @@ BENCH_ARGS$(2) := $$(CTEST_COMMON_ARGS$(2)) \
--mode run-pass \ --mode run-pass \
$$(CTEST_RUNTOOL) \ $$(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)) \ PRETTY_RPASS_ARGS$(2) := $$(CTEST_COMMON_ARGS$(2)) \
--src-base $$(S)src/test/run-pass/ \ --src-base $$(S)src/test/run-pass/ \
--build-base test/run-pass/ \ --build-base test/run-pass/ \
@ -253,6 +271,12 @@ test/bench.stage$(2).out.tmp: test/compiletest.stage$(2)$$(X) \
$$(Q)$$(call CFG_RUN_CTEST,$(2),$$<) $$(BENCH_ARGS$(2)) $$(Q)$$(call CFG_RUN_CTEST,$(2),$$<) $$(BENCH_ARGS$(2))
$$(Q)touch $$@ $$(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) \ test/pretty-rpass.stage$(2).out.tmp: test/compiletest.stage$(2)$$(X) \
$$(RPASS_TESTS) $$(RPASS_TESTS)
@$$(call E, run: $$<) @$$(call E, run: $$<)