PetaVision  Alpha
Timer.hpp
1 /*
2  * Timer.hpp
3  *
4  * Created by Craig Rasmussen on 11/15/09.
5  * Copyright 2009 Los Alamos National Laboratory. All rights reserved.
6  *
7  */
8 
9 #ifndef TIMER_HPP_
10 #define TIMER_HPP_
11 
12 #include <assert.h>
13 #include <ostream>
14 #include <stddef.h>
15 #include <stdint.h>
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19 
20 #include "io/PrintStream.hpp"
21 
23 
24 namespace PV {
25 
26 class Timer {
27  public:
28  Timer(double init_time = 0.0);
29  Timer(const char *timermessage, double init_time = 0.0);
30  Timer(const char *objname, const char *objtype, const char *timertype, double init_time = 0.0);
31  virtual ~Timer();
32  void reset(double init_time = 0.0);
33 
34  virtual double start();
35  virtual double stop();
36  inline double elapsed_time() const;
37  virtual int fprint_time(PrintStream &stream) const;
38 
39  protected:
40  int rank;
41  char *message;
42 
43  uint64_t time_start, time_end;
44  uint64_t time_elapsed;
45 };
46 
47 } // namespace PV
48 
49 #endif /* TIMER_HPP_ */