diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2014-09-05 12:43:34 +0200 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2014-09-05 13:47:57 +0200 |
commit | 1444316d320d32ef3da1bfe5dcb6805e2e65cc08 (patch) | |
tree | 557bc36901150a461b3eb12edd6efceb6e0d61b6 /solenv/gbuild/CppunitTest.mk | |
parent | 845fb7bf6753ec9582d0b1d1c9b4276aa9e6c65e (diff) |
gbuild: Framework for performance unit tests using callgrind
Run them with "make perfcheck" (toplevel or in a module)
To add a new performance test:
- Add it as a perfcheck target
- Use gb_CppunitTest_set_performance_test
- Use CALLGRIND_ macros from valgrind/callgrind.h
http://valgrind.org/docs/manual/cl-manual.html#cl-manual.clientrequests
Change-Id: I67c776dbe4db0a686607efeee7a7e4f3aeae0e5c
Diffstat (limited to 'solenv/gbuild/CppunitTest.mk')
-rw-r--r-- | solenv/gbuild/CppunitTest.mk | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/solenv/gbuild/CppunitTest.mk b/solenv/gbuild/CppunitTest.mk index 4599dae58d5b..a7d1afa382f5 100644 --- a/solenv/gbuild/CppunitTest.mk +++ b/solenv/gbuild/CppunitTest.mk @@ -94,7 +94,10 @@ $(call gb_CppunitTest_get_target,%) :| $(gb_CppunitTest_CPPTESTDEPS) || ($(if $(value gb_CppunitTest_postprocess), \ RET=$$?; \ $(call gb_CppunitTest_postprocess,$(gb_CppunitTest_CPPTESTCOMMAND),$@.core,$$RET) >> $@.log 2>&1;) \ - cat $@.log; $(SRCDIR)/solenv/bin/unittest-failed.sh Cppunit $*)))) + cat $@.log; $(SRCDIR)/solenv/bin/unittest-failed.sh Cppunit $*))) \ + $(if $(PERFTEST), && VAL=$$(grep '^==.*== Collected : ' $@.log | sed "s/==.*== Collected : //") && \ + $(if $(filter 0,$(PERFTEST)), expr "$$VAL" "*" "101" "/" "100", test $$VAL -le $(PERFTEST) || (echo "Unit test is slow! $$VAL instructions detected." && false))) \ + ) define gb_CppunitTest_CppunitTest $(call gb_CppunitTest__CppunitTest_impl,$(1),$(call gb_CppunitTest_get_linktarget,$(1))) @@ -144,6 +147,21 @@ $(call gb_CppunitTest_get_target,$(1)) : ARGS += $(2) endef +# Run this unit test with callgrind tool to measure performance. If you are +# creating a new test, first set the number to 0, run the test, and it will +# print an number for you to use as a second parameter here. The test will +# fail if reported number of instructions will be bigger than this parameter. +# +# call gb_CppunitTest_set_performance_test,name,instructions_number +define gb_CppunitTest_set_performance_test +$(if $(ENABLE_VALGRIND),,$(call gb_Output_error,gb_CppunitTest_set_performance_test used with empty $$(ENABLE_VALGRIND))) + +$(call gb_CppunitTest_get_target,$(1)) : PERFTEST := $(2) +$(call gb_CppunitTest_get_target,$(1)) : gb_CppunitTest_VALGRINDTOOL := valgrind --tool=callgrind --dump-instr=yes --instr-atstart=no +$(call gb_CppunitTest_use_external,$(1),valgrind) + +endef + define gb_CppunitTest_use_ure $(call gb_CppunitTest_use_rdb,$(1),ure/services) $(call gb_CppunitTest_get_target,$(1)) : URE := $(true) |