aboutsummaryrefslogtreecommitdiffstats
path: root/checks/timer.h
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-08-31 02:42:44 +0000
committerlloyd <[email protected]>2008-08-31 02:42:44 +0000
commit312d91067111c3de445c2ca9d31e2eb6fed3c332 (patch)
tree97b8ce89867a662ae2de6e3dd32a2859bc25c81f /checks/timer.h
parentdc2752448ddef6e96ad81bbf585fcaf971eeaf5f (diff)
Add a simple timer class
Diffstat (limited to 'checks/timer.h')
-rw-r--r--checks/timer.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/checks/timer.h b/checks/timer.h
new file mode 100644
index 000000000..80aeec9e6
--- /dev/null
+++ b/checks/timer.h
@@ -0,0 +1,50 @@
+
+#ifndef BOTAN_BENCHMARK_TIMER_H__
+#define BOTAN_BENCHMARK_TIMER_H__
+
+#include <botan/types.h>
+#include <ostream>
+#include <string>
+
+using Botan::u64bit;
+using Botan::u32bit;
+
+class Timer
+ {
+ public:
+ static u64bit get_clock();
+
+ Timer(const std::string& name);
+
+ void start();
+
+ void stop();
+
+ u64bit value();
+ double seconds();
+ double milliseconds();
+
+ double ms_per_event();
+ double seconds_per_event();
+
+ u32bit events() const { return event_count; }
+ std::string get_name() const { return name; }
+ private:
+ std::string name;
+ u64bit time_used, timer_start;
+ u32bit event_count;
+ };
+
+inline bool operator<(const Timer& x, const Timer& y)
+ {
+ return (x.get_name() < y.get_name());
+ }
+
+inline bool operator==(const Timer& x, const Timer& y)
+ {
+ return (x.get_name() == y.get_name());
+ }
+
+std::ostream& operator<<(std::ostream&, Timer&);
+
+#endif