CARMA C++
TimedBenchmark.h
1 /*
2  * Easy Clock and Benchmark Utility Objects
3  *
4  * Copyright (c) 2010 Ira W. Snyder <iws@ovro.caltech.edu>
5  */
6 
7 #ifndef TIMED_BENCHMARK_H
8 #define TIMED_BENCHMARK_H
9 
10 #include <boost/date_time/posix_time/posix_time.hpp>
11 
12 namespace carma {
13 namespace util {
14 
15 class TimedBenchmark
16 {
17  public:
18  void reset();
19  void start();
20  void stop();
21  std::string print() const;
22  double milliseconds() const;
23 
24  private:
25  boost::posix_time::ptime start_time;
26  boost::posix_time::ptime stop_time;
27 };
28 
29 class EasyClock
30 {
31  public:
32  EasyClock();
33 
34  /* capture a time reading */
35  void read();
36 
37  /* convert to milliseconds */
38  static double milliseconds(const EasyClock &lhs, const EasyClock &rhs);
39 
40  private:
41  boost::posix_time::ptime time;
42 };
43 
44 }} // namespace carma::util
45 #endif /* TIMED_BENCHMARK_H */