]> Dogcows Code - chaz/yoink/blobdiff - src/stlplus/subsystems/timer.hpp
testing new non-autotools build system
[chaz/yoink] / src / stlplus / subsystems / timer.hpp
diff --git a/src/stlplus/subsystems/timer.hpp b/src/stlplus/subsystems/timer.hpp
new file mode 100644 (file)
index 0000000..a3ad38d
--- /dev/null
@@ -0,0 +1,56 @@
+#ifndef STLPLUS_TIMER\r
+#define STLPLUS_TIMER\r
+////////////////////////////////////////////////////////////////////////////////\r
+\r
+//   Author:    Andy Rushton\r
+//   Copyright: (c) Southampton University 1999-2004\r
+//              (c) Andy Rushton           2004-2009\r
+//   License:   BSD License, see ../docs/license.html\r
+\r
+//   A CPU timer encapsulated as a class. Measures the CPU time used since its\r
+//   construction and allows this cumulative time to be reported at any time.\r
+\r
+////////////////////////////////////////////////////////////////////////////////\r
+#include "subsystems_fixes.hpp"\r
+#include <time.h>\r
+#include <string>\r
+#include <iostream>\r
+\r
+namespace stlplus\r
+{\r
+\r
+  ////////////////////////////////////////////////////////////////////////////////\r
+\r
+  class timer\r
+  {\r
+  private:\r
+    clock_t m_clock;\r
+    time_t m_time;\r
+\r
+  public:\r
+    // constructor resets the timer to zero\r
+    timer(void);\r
+    ~timer(void);\r
+\r
+    // reset the timer to zero without destroying it\r
+    void reset(void);\r
+\r
+    // get the elapsed time in seconds, expressed as a float\r
+    float elapsed(void) const;\r
+    // get the CPU time in seconds, expressed as a float\r
+    float cpu(void) const;\r
+\r
+    // get a printable string representing the elapsed time and CPU time\r
+    std::string text(void) const;\r
+  };\r
+\r
+  ////////////////////////////////////////////////////////////////////////////////\r
+\r
+  // print the elapsed time and CPU time using the same representation as the text method\r
+  std::ostream& operator << (std::ostream&, const timer&);\r
+\r
+  ////////////////////////////////////////////////////////////////////////////////\r
+\r
+} // end namespace stlplus\r
+\r
+#endif\r
This page took 0.021341 seconds and 4 git commands to generate.