28 #ifndef _util_misc_regtime_h
29 #define _util_misc_regtime_h
34 #ifdef MPQC_NEW_FEATURES
37 #include <mpqc_config.h>
38 #include <util/class/class.h>
43 class MultiThreadTimer;
66 const char *name()
const {
return name_; }
69 void cpu_enter(
double);
70 void wall_enter(
double);
71 void flops_enter(
double);
72 void cpu_exit(
double);
73 void wall_exit(
double);
74 void flops_exit(
double);
75 void cpu_add(
double t) { cpu_time_ += t; }
76 void wall_add(
double t) { wall_time_ += t; }
77 void flops_add(
double t) { flops_ += t; }
79 TimedRegion *subregions()
const {
return subregions_; }
86 double wall_time()
const {
return wall_time_; }
87 double flops()
const {
return flops_; }
91 void merge(
const TimedRegion* r);
94 void get_region_names(
const char *names[]);
95 void get_wall_times(
double *);
96 void get_cpu_times(
double *);
97 void get_flops(
double *);
98 void get_depth(
int *,
int depth = 0);
100 #if MPQC_NEW_FEATURES
101 friend class MultiThreadTimer;
103 friend class RegionTimer;
119 std::list<TimedRegion*> defaults_;
123 int cpu_time = 0,
int wall_time = 1);
126 void enter(
const char * = 0);
127 void change(
const char *newname,
const char * oldname = 0);
128 void exit(
const char * = 0,
bool do_not_throw =
false);
129 double cpu_time(
const char * name = 0)
const;
130 double wall_time(
const char * name = 0)
const;
131 double flops(
const char * name = 0)
const;
132 void set_default(
const char *);
133 void unset_default();
134 void enter_default();
142 void update_top()
const;
145 void get_region_names(
const char *names[])
const;
146 void get_wall_times(
double *)
const;
147 void get_cpu_times(
double *)
const;
148 void get_flops(
double *)
const;
149 void get_depth(
int *)
const;
156 static double get_flops();
158 #ifdef MPQC_NEW_FEATURES
159 static std::chrono::time_point<std::chrono::high_resolution_clock>
164 void add_wall_time(
const char *,
double);
165 void add_cpu_time(
const char *,
double);
166 void add_flops(
const char *,
double);
185 bool default_entered_;
190 Timer(
const char *name);
192 Timer(
const std::string &name);
212 DEPRECATED
void reset(
const char * = 0);
219 void enter(
const char *region);
220 void enter(
const std::string ®ion) {
enter(region.c_str()); }
225 void change(
const char *region);
226 void change(
const std::string ®ion) {
change(region.c_str()); }
231 void exit(
const char *region = 0);
232 void exit(
const std::string ®ion) { this->
exit(region.c_str()); }
245 void unset_default();
246 void enter_default();
251 double cpu_time(
const char *region)
const;
252 double cpu_time(
const std::string ®ion)
const {
return cpu_time(region.c_str()); }
253 double wall_time(
const char *region)
const;
254 double wall_time(
const std::string ®ion)
const {
return wall_time(region.c_str()); }
255 double flops(
const char *region)
const;
256 double flops(
const std::string ®ion)
const {
return flops(region.c_str()); }
259 #if MPQC_NEW_FEATURES
void merge(const TimedRegion *r)
Include the regions in r in this object's regions.
The Timer class uses RegionTimer to time intervals in an exception safe manner.
Definition: regtime.h:181
A template class that maintains references counts.
Definition: ref.h:361
void acquire_timed_region(TimedRegion *r)
Add r as a subregion of current_. After invocation, r is owned by this RegionTimer.
virtual void print(std::ostream &=ExEnv::out0()) const
Print the object.
DEPRECATED void reset(const char *=0)
Stop timing the current region, if active.
void enter(const char *region)
Begin timing, using the given timing region name.
static double get_wall_time()
Definition: thread_timer.h:438
double cpu_time() const
reports the current values of cpu_time, wall_time, and flops
Definition: regtime.h:85
void exit(const char *region=0)
Exit the current timing region.
TimedRegion is a helper class for RegionTimer.
Definition: regtime.h:47
Timer()
Construct a Timer object using the default RegionTimer and do not begin timing a region.
void print(std::ostream &=ExEnv::out0()) const
Print the timings held by this object's RegionTimer.
static double get_cpu_time()
Classes which need runtime information about themselves and their relationship to other classes can v...
Definition: class.h:233
~Timer()
Stop timing a region, if active.
static std::ostream & out0()
Return an ostream that writes from node 0.
void merge(const Ref< RegionTimer > &r)
Include the regions in r in this object's regions.
void change(const char *region)
Change the current timing region to the one specified by the given name.
The RegionTimer class is used to record the time spent in a section of code.
Definition: regtime.h:110
void set_default(const char *region)
Default timing regions are provided as a performance optimization.
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14
double cpu_time(const char *region) const
Query the timers and flop counter for the region.
Generated at Sun Jan 26 2020 23:24:02 for MPQC
3.0.0-alpha using the documentation package Doxygen
1.8.16.