]> Dogcows Code - chaz/yoink/blob - src/stlplus/subsystems/timer.hpp
testing new non-autotools build system
[chaz/yoink] / src / stlplus / subsystems / timer.hpp
1 #ifndef STLPLUS_TIMER
2 #define STLPLUS_TIMER
3 ////////////////////////////////////////////////////////////////////////////////
4
5 // Author: Andy Rushton
6 // Copyright: (c) Southampton University 1999-2004
7 // (c) Andy Rushton 2004-2009
8 // License: BSD License, see ../docs/license.html
9
10 // A CPU timer encapsulated as a class. Measures the CPU time used since its
11 // construction and allows this cumulative time to be reported at any time.
12
13 ////////////////////////////////////////////////////////////////////////////////
14 #include "subsystems_fixes.hpp"
15 #include <time.h>
16 #include <string>
17 #include <iostream>
18
19 namespace stlplus
20 {
21
22 ////////////////////////////////////////////////////////////////////////////////
23
24 class timer
25 {
26 private:
27 clock_t m_clock;
28 time_t m_time;
29
30 public:
31 // constructor resets the timer to zero
32 timer(void);
33 ~timer(void);
34
35 // reset the timer to zero without destroying it
36 void reset(void);
37
38 // get the elapsed time in seconds, expressed as a float
39 float elapsed(void) const;
40 // get the CPU time in seconds, expressed as a float
41 float cpu(void) const;
42
43 // get a printable string representing the elapsed time and CPU time
44 std::string text(void) const;
45 };
46
47 ////////////////////////////////////////////////////////////////////////////////
48
49 // print the elapsed time and CPU time using the same representation as the text method
50 std::ostream& operator << (std::ostream&, const timer&);
51
52 ////////////////////////////////////////////////////////////////////////////////
53
54 } // end namespace stlplus
55
56 #endif
This page took 0.029759 seconds and 4 git commands to generate.