OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimTimer.h
Go to the documentation of this file.
1 /*
2  * This code was taken from the OpenScene graph.
3  */
4 
5 #ifndef ossimTimer_HEADER
6 #define ossimTimer_HEADER 1
7 #include "ossimConstants.h"
8 
11 {
12 public:
13 #if defined(_MSC_VER)
14  typedef __int64 Timer_t;
15 #else
16  typedef unsigned long long Timer_t;
17 #endif
18  ossimTimer();
19  ~ossimTimer() {m_instance = 0;}
20 
21  static ossimTimer* instance();
22 
24  Timer_t tick() const;
25 
27  void setStartTick() { m_startTick = tick(); }
28  void setStartTick(Timer_t t) { m_startTick = t; }
29  Timer_t getStartTick() const { return m_startTick; }
30 
31 
33  inline double time_s() const { return delta_s(m_startTick, tick()); }
34 
36  inline double time_m() const { return delta_m(m_startTick, tick()); }
37 
39  inline double time_u() const { return delta_u(m_startTick, tick()); }
40 
42  inline double time_n() const { return delta_n(m_startTick, tick()); }
43 
45  inline double delta_s( Timer_t t1, Timer_t t2 ) const { return (double)(t2 - t1)*m_secsPerTick; }
46  inline double delta_s( Timer_t t1) const { return (double)(tick() - t1)*m_secsPerTick; }
47 
49  inline double delta_m( Timer_t t1, Timer_t t2 ) const { return delta_s(t1,t2)*1e3; }
50  inline double delta_m( Timer_t t1) const { return delta_s(t1,tick())*1e3; }
51 
53  inline double delta_u( Timer_t t1, Timer_t t2 ) const { return delta_s(t1,t2)*1e6; }
54  inline double delta_u( Timer_t t1) const { return delta_s(t1,tick())*1e6; }
55 
57  inline double delta_n( Timer_t t1, Timer_t t2 ) const { return delta_s(t1,t2)*1e9; }
58  inline double delta_n( Timer_t t1) const { return delta_s(t1,tick())*1e9; }
59 
61  inline double getSecondsPerTick() const { return m_secsPerTick; }
62 
63 protected:
66  double m_secsPerTick;
67 
68 };
69 #endif
Timer_t m_startTick
Definition: ossimTimer.h:65
void setStartTick()
Set the start.
Definition: ossimTimer.h:27
unsigned long long Timer_t
Definition: ossimTimer.h:16
double delta_m(Timer_t t1, Timer_t t2) const
Get the time in milliseconds between timer ticks t1 and t2.
Definition: ossimTimer.h:49
double delta_u(Timer_t t1) const
Definition: ossimTimer.h:54
double delta_m(Timer_t t1) const
Definition: ossimTimer.h:50
double time_m() const
Get elapsed time in milliseconds.
Definition: ossimTimer.h:36
double getSecondsPerTick() const
Get the the number of seconds per tick.
Definition: ossimTimer.h:61
void setStartTick(Timer_t t)
Definition: ossimTimer.h:28
Timer_t getStartTick() const
Definition: ossimTimer.h:29
double time_s() const
Get elapsed time in seconds.
Definition: ossimTimer.h:33
Timer class is used for measuring elapsed time or time between two points.
Definition: ossimTimer.h:10
double time_u() const
Get elapsed time in micoseconds.
Definition: ossimTimer.h:39
double time_n() const
Get elapsed time in nanoseconds.
Definition: ossimTimer.h:42
double m_secsPerTick
Definition: ossimTimer.h:66
double delta_u(Timer_t t1, Timer_t t2) const
Get the time in microseconds between timer ticks t1 and t2.
Definition: ossimTimer.h:53
double delta_n(Timer_t t1, Timer_t t2) const
Get the time in nanoseconds between timer ticks t1 and t2.
Definition: ossimTimer.h:57
#define OSSIM_DLL
static ossimTimer * m_instance
Definition: ossimTimer.h:64
double delta_s(Timer_t t1) const
Definition: ossimTimer.h:46
double delta_s(Timer_t t1, Timer_t t2) const
Get the time in seconds between timer ticks t1 and t2.
Definition: ossimTimer.h:45
double delta_n(Timer_t t1) const
Definition: ossimTimer.h:58