~jesterking/blender/win32libs

« back to all changes in this revision

Viewing changes to openimageio/include/OpenImageIO/timer.h

  • Committer: dingto
  • Date: 2013-12-06 17:01:28 UTC
  • Revision ID: svn-v4:954f8c5b-7b00-dc11-b283-0030488c597c:trunk/lib/windows:61249
MSVC 2008 x86
* Update OSL to 1.4.0 and OIIO to 1.3.9.

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
///    another.reset ();             // reset to zero time again
70
70
/// \endcode
71
71
///
 
72
/// These are not very high-resolution timers.  A Timer begin/end pair
 
73
/// takes somewhere in the neighborhood of 0.1 - 0.3 us (microseconds),
 
74
/// and can vary by OS.  This means that (a) it's not useful for timing
 
75
/// individual events near or below that resolution (things that would
 
76
/// take only tens or hundreds of processor cycles, for example), and
 
77
/// (b) calling it millions of times could make your program appreciably
 
78
/// more expensive due to the timers themselves.
 
79
///
72
80
class Timer {
73
81
public:
74
82
#ifdef _WIN32
86
94
    {
87
95
        if (startnow)
88
96
            start();
 
97
        else {
 
98
            // Initialize m_starttime to avoid warnings
 
99
#ifdef _WIN32
 
100
            m_starttime.QuadPart = 0;
 
101
#elif defined(__APPLE__)
 
102
            m_starttime = 0;
 
103
#else
 
104
            m_starttime.tv_sec = 0;
 
105
            m_starttime.tv_usec = 0;
 
106
#endif
 
107
        }
89
108
    }
90
109
 
91
110
    /// Destructor.
122
141
 
123
142
    /// Return just the time of the current lap (since the last call to
124
143
    /// start() or lap()), add that to the previous elapsed time, reset
125
 
    /// current start tiem to now, keep the timer going (if it was).
 
144
    /// current start time to now, keep the timer going (if it was).
126
145
    double lap () {
127
146
        value_t n = now();
128
147
        double r = m_ticking ? diff (m_starttime, n) : 0.0;