From a3e89e25bc368c7e917ee9c8f70d05d8b5297457 Mon Sep 17 00:00:00 2001 From: guido Date: Wed, 16 Feb 2000 05:31:39 +0000 Subject: [PATCH] timer check git-svn-id: https://svn.dealii.org/trunk@2411 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/base/Makefile | 16 ++++++++--- tests/base/timer.cc | 62 ++++++++++++++++++++++++++++++++++++++++ tests/base/timer.checked | 4 +++ 3 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 tests/base/timer.cc create mode 100644 tests/base/timer.checked 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