aboutsummaryrefslogtreecommitdiff
path: root/Carpet/Carpet/src/CactusTimer.hh
blob: cab4c592ab5927f91b63970961aa15fc1a9916e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef CACTUSTIMER_HH
#define CACTUSTIMER_HH

#include <cctk.h>

#include <iostream>
#include <list>
#include <string>
#include <utility>
#include <vector>

namespace Carpet {

  using namespace std;

/** The CactusTimer class wraps the Cactus timer mechanism.  All times
    are returned as doubles for now. */

  class CactusTimer
  {
    int handle;
    bool running;

  public:

    /// Create a new Cactus timer with the given name
    CactusTimer (const string &timername);

    /// Destroy a timer
    ~CactusTimer ();

    /// Start the timer
    void start ();

    /// Stop the timer
    void stop ();

    /// Reset the timer
    void reset ();

    /// Timer name
    string name () const;

    /// Return the current time of the timer in seconds as a double
    double getTime();

    /// Return the average and maximum current time over all MPI processes
    void getGlobalTime(double& avg, double& max);

    /// Return all clock names and their units
    vector<pair<string,string> > getAllTimerNames() const;

    /// Return all clock values of the timer as double
    vector<double> getAllTimerValues();

    /// Print timer data
    void printData ();

    ostream& serialise(ostream &os);

  private:

    // Output (debug) messages that a timer is starting or stopping
    void
    msgStart ()
      const;

    void
    msgStop ()
      const;

  };
}  // namespace Carpet

#endif // CACTUSTIMER_HH