]> git.lizzy.rs Git - rust.git/commitdiff
Add build-system mechanisms for running benchmarks under 'perf'.
authorGraydon Hoare <graydon@mozilla.com>
Tue, 13 Sep 2011 22:06:21 +0000 (15:06 -0700)
committerGraydon Hoare <graydon@mozilla.com>
Tue, 13 Sep 2011 22:06:41 +0000 (15:06 -0700)
Makefile.in
configure
mk/perf.mk [new file with mode: 0644]
mk/platform.mk
mk/tests.mk

index dbd98a31c00f40b96b9335631bfe3e23247677cf..bdb55e1c574bbc336208c689f736137d13026536 100644 (file)
@@ -271,11 +271,17 @@ endif
 
 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
index c1474edb0d7c79de0780d810eda5aa3703642ad9..f6b6d8f5c4a374710b1a029a52777a52a06e5231 100755 (executable)
--- a/configure
+++ b/configure
@@ -183,7 +183,8 @@ for i in \
     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
@@ -205,6 +206,7 @@ probe CFG_CLANG            clang++
 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
diff --git a/mk/perf.mk b/mk/perf.mk
new file mode 100644 (file)
index 0000000..9e7ffc6
--- /dev/null
@@ -0,0 +1 @@
+perf: check-stage2-perf
index a647e9cb3c555c2e86730b291d70115e0fff1d4a..c7cd36331fb021e7e4fd079ee7abe0aeaf35f1e9 100644 (file)
@@ -34,6 +34,35 @@ ifeq ($(CFG_OSTYPE), Linux)
   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)
index c99a8cc61d29b4b65e23003b3aa1628ff1be9edf..6b28c16b2d13631ba6e41950fde6dc4fc28c3754 100644 (file)
@@ -15,10 +15,15 @@ CFAIL_RS := $(wildcard $(S)src/test/compile-fail/*.rs)
 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
@@ -40,6 +45,11 @@ ifdef CFG_VALGRIND
   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
@@ -150,7 +160,7 @@ test/rustctest.stage$(2).out.tmp: test/rustctest.stage$(2)$$(X)
        $$(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 \
 
@@ -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)-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 \
@@ -203,6 +215,12 @@ BENCH_ARGS$(2) := $$(CTEST_COMMON_ARGS$(2)) \
                   --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/ \
@@ -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)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: $$<)