1/* -*-c++-*- OpenSceneGraph - Copyright (C) Sketchfab */
2
3#ifndef STAT_LOGGER
4#define STAT_LOGGER
5
6#include <osg/Timer>
7#include <osg/Notify>
8
9
10class StatLogger
11{
12public:
13    StatLogger(const std::string& label):
14        _label(label)
15    {
16        _start = _stop = getTick();
17    }
18
19
20    ~StatLogger() {
21        _stop = getTick();
22
23        OSG_INFO << std::endl
24                 << "Info: " << _label << " timing: " << getElapsedSeconds() << "s"
25                 << std::endl;
26    }
27
28protected:
29    osg::Timer_t _start, _stop;
30    std::string _label;
31
32    inline osg::Timer_t getTick() const {
33        return osg::Timer::instance()->tick();
34    }
35
36    inline double getElapsedSeconds() const {
37        return osg::Timer::instance()->delta_s(_start, _stop);
38    }
39};
40
41#endif
42