From c986f6ea41e418852631d5f1d6a6ac20a702c203 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 3 Jul 2006 13:53:39 +0000 Subject: [PATCH] Added a performace test section to osgunitests, currently just does basic C/C++ tests. --- .../examples/osgunittests/osgunittests.dsp | 17 ++ examples/osgunittests/GNUmakefile | 1 + examples/osgunittests/osgunittests.cpp | 14 ++ examples/osgunittests/performance.cpp | 182 ++++++++++++++++++ examples/osgunittests/performance.h | 6 + 5 files changed, 220 insertions(+) create mode 100644 examples/osgunittests/performance.cpp create mode 100644 examples/osgunittests/performance.h diff --git a/VisualStudio/examples/osgunittests/osgunittests.dsp b/VisualStudio/examples/osgunittests/osgunittests.dsp index 980d09dfc..3e1485f92 100644 --- a/VisualStudio/examples/osgunittests/osgunittests.dsp +++ b/VisualStudio/examples/osgunittests/osgunittests.dsp @@ -85,14 +85,31 @@ LINK32=link.exe # Name "Example osgunittests - Win32 Release" # Name "Example osgunittests - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\..\..\examples\osgunittests\osgunittests.cpp # End Source File # Begin Source File +SOURCE=..\..\..\examples\osgunittests\performance.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter ";h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=..\..\..\examples\performance\performance.h +# End Source File +# Begin Source File + SOURCE=..\..\icons\osg_icon.rc # End Source File +# End Group + # End Target # Begin Group "Resource Files" diff --git a/examples/osgunittests/GNUmakefile b/examples/osgunittests/GNUmakefile index c44115315..bb5dd2aa7 100644 --- a/examples/osgunittests/GNUmakefile +++ b/examples/osgunittests/GNUmakefile @@ -2,6 +2,7 @@ TOPDIR = ../.. include $(TOPDIR)/Make/makedefs CXXFILES =\ + performance.cpp\ osgunittests.cpp\ LIBS += -losgProducer -lProducer -losgText -losgGA -losgDB -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) diff --git a/examples/osgunittests/osgunittests.cpp b/examples/osgunittests/osgunittests.cpp index 827261c67..117cbd6d1 100644 --- a/examples/osgunittests/osgunittests.cpp +++ b/examples/osgunittests/osgunittests.cpp @@ -6,6 +6,8 @@ #include #include +#include "performance.h" + #include void testFrustum(double left,double right,double bottom,double top,double zNear,double zFar) @@ -192,6 +194,7 @@ int main( int argc, char** argv ) arguments.getApplicationUsage()->addCommandLineOption("qt","Display qualified tests."); arguments.getApplicationUsage()->addCommandLineOption("sizeof","Display sizeof tests."); arguments.getApplicationUsage()->addCommandLineOption("matrix","Display qualified tests."); + arguments.getApplicationUsage()->addCommandLineOption("performance","Display qualified tests."); if (arguments.argc()<=1) @@ -212,6 +215,9 @@ int main( int argc, char** argv ) bool printQuatTest = false; while (arguments.read("quat")) printQuatTest = true; + bool performanceTest = false; + while (arguments.read("p") || arguments.read("performance")) performanceTest = true; + // if user request help write it out to cout. if (arguments.read("-h") || arguments.read("--help")) { @@ -264,6 +270,14 @@ int main( int argc, char** argv ) } + if (performanceTest) + { + std::cout<<"**** performance tests ******"< +#include + +struct Benchmark +{ + + Benchmark() + { + calibrate(); + + _beginTick = _timer.tick(); + _endTick = _timer.tick(); + } + + void calibrate(unsigned int numLoops = 100000) + { + osg::Timer_t beginTick = _timer.tick(); + for(unsigned int i=0;i=1.0) std::cout<=0.001) std::cout<=0.000001) std::cout<(vm4))->method(), iterations) + RUN(benchmark, (static_cast(vm4))->method(), iterations) + RUN(benchmark, { VirtualMethod mm; mm.method(); }, iterations) + RUN(benchmark, { VirtualMethod2 mm; mm.method(); }, iterations) +} diff --git a/examples/osgunittests/performance.h b/examples/osgunittests/performance.h new file mode 100644 index 000000000..e57a6773a --- /dev/null +++ b/examples/osgunittests/performance.h @@ -0,0 +1,6 @@ +#ifndef PERFORMANCE_H +#define PERFORMANCE_H 1 + +extern void runPerformanceTests(); + +#endif