hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
HCETimer.hpp
Go to the documentation of this file.
1 
8 #ifndef _HCE_TIMER_HPP
9 #define _HCE_TIMER_HPP
10 
11 
12 #include <Poco/Timestamp.h>
13 #include <ctime>
14 #include <iostream>
15 
16 
17 using Poco::Timestamp;
18 
19 
20 namespace HCE
21 {
22 
23 
24 class HCETimer
25 {
26  public:
27  explicit HCETimer( const std::string& s = "Time: " ) : _prompt( s ), _start() {}
28  ~HCETimer() { _stop = _start.elapsed(); std::cout << _prompt << toSeconds( _stop ) << std::endl; }
29  public:
30  inline static const double toSeconds( const Timestamp::TimeDiff& microseconds ) { return microseconds / 1000000.; }
31  private:
32  std::string _prompt;
33  Timestamp _start;
34  Timestamp::TimeDiff _stop;
35 };
36 
37 
38 } /* namespace HCE */
39 
40 
41 #endif