From: guido Date: Wed, 16 Feb 2000 05:31:39 +0000 (+0000) Subject: timer check X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a3e89e25bc368c7e917ee9c8f70d05d8b5297457;p=dealii-svn.git timer check git-svn-id: https://svn.dealii.org/trunk@2411 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/base/Makefile b/tests/base/Makefile index e033fc3601..f276f0a3e6 100644 --- a/tests/base/Makefile +++ b/tests/base/Makefile @@ -59,7 +59,7 @@ endif @$(CXX) $(flags) -c $< -o $@ -all: logtest.check reference.check tensor.check quadrature_test.check +all: logtest.check reference.check tensor.check quadrature_test.check timer.check exe: $(all:.check=.testcase) output: $(all:.check=.output) ############################################################ @@ -137,10 +137,18 @@ quadrature_test.testcase: $(quadrature_test-o-files) $(libraries) @$(CXX) $(flags) -o $@ $^ -############################################################ -# Continue with other targets if needed -############################################################ +timer-cc-files = timer.cc + +ifeq ($(debug-mode),on) +timer-o-files = $(timer-cc-files:.cc=.go) +else +timer-o-files = $(timer-cc-files:.cc=.o) +endif + +timer.testcase: $(timer-o-files) $(libraries) + @echo =====linking======= $< + @$(CXX) $(flags) -o $@ $^ ############################################################ # Continue with other targets if needed diff --git a/tests/base/timer.cc b/tests/base/timer.cc new file mode 100644 index 0000000000..3d0e092ad2 --- /dev/null +++ b/tests/base/timer.cc @@ -0,0 +1,62 @@ +// $Id$ +// (c) Guido Kanschat, 2000 + +#include +#include +#include + +// compute the ratio of two measurements and compare to +// the expected value. + +void compare (double t1, double t2, double ratio) +{ + double r = t2/t1; + double d = fabs(r-ratio) / ratio; + + // relative error < 10%? + if (d <= .1) + { + deallog << "OK" << endl; + } else { + deallog << "Ratio " << r << " should be " << ratio << endl; + } +} + +// burn computer time + +void burn (unsigned int n) +{ + double s; + for (unsigned int i=0 ; i