git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14770 16af8721-9629-0410-8352-f15c8da7e697
33 lines
695 B
Plaintext
33 lines
695 B
Plaintext
#ifndef STAT_LOGGER
|
|
#define STAT_LOGGER
|
|
|
|
#include <osg/Timer>
|
|
#include <osg/Notify>
|
|
|
|
|
|
class StatLogger
|
|
{
|
|
public:
|
|
StatLogger(const std::string& label): _start(getTick()), _label(label) {}
|
|
~StatLogger() {
|
|
_stop = getTick();
|
|
OSG_INFO << std::flush
|
|
<< "Info: " << _label << " timing: " << getElapsedSeconds() << "s"
|
|
<< std::endl << std::flush;
|
|
}
|
|
|
|
protected:
|
|
osg::Timer_t _start, _stop;
|
|
std::string _label;
|
|
|
|
inline osg::Timer_t getTick() const {
|
|
return osg::Timer::instance()->tick();
|
|
}
|
|
|
|
inline double getElapsedSeconds() const {
|
|
return osg::Timer::instance()->delta_s(_start, _stop);
|
|
}
|
|
};
|
|
|
|
#endif
|