/* OpenSceneGraph example, osgunittests. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include "performance.h" #include #include #include #include #include #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) osg::ref_ptr group = new osg::Group; osg::ref_ptr mt = new osg::MatrixTransform; osg::Node* m = mt.get(); CustomNodeVisitor cnv; RUN(benchmark, { osg::MatrixTransform* mtl = dynamic_cast(m); if (mtl) cnv.apply(*mtl); }, 1000) RUN(benchmark, { m->accept(cnv); }, 10000) }