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>
43class 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_; }
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);
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
160 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_;
212 DEPRECATED
void reset(
const char * = 0);
220 void enter(
const std::string ®ion) {
enter(region.c_str()); }
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();
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()); }
260 void insert(
const MultiThreadTimer& timer);
Classes which need runtime information about themselves and their relationship to other classes can v...
Definition class.h:233
static std::ostream & out0()
Return an ostream that writes from node 0.
Definition thread_timer.h:438
A template class that maintains references counts.
Definition ref.h:361
The RegionTimer class is used to record the time spent in a section of code.
Definition regtime.h:110
static double get_cpu_time()
virtual void print(std::ostream &=ExEnv::out0()) const
Print the object.
void acquire_timed_region(TimedRegion *r)
Add r as a subregion of current_. After invocation, r is owned by this RegionTimer.
static double get_wall_time()
void merge(const Ref< RegionTimer > &r)
Include the regions in r in this object's regions.
TimedRegion is a helper class for RegionTimer.
Definition regtime.h:47
void merge(const TimedRegion *r)
Include the regions in r in this object's regions.
double cpu_time() const
reports the current values of cpu_time, wall_time, and flops
Definition regtime.h:85
The Timer class uses RegionTimer to time intervals in an exception safe manner.
Definition regtime.h:181
double cpu_time(const char *region) const
Query the timers and flop counter for the region.
~Timer()
Stop timing a region, if active.
void change(const char *region)
Change the current timing region to the one specified by the given name.
void set_default(const char *region)
Default timing regions are provided as a performance optimization.
Timer(const std::string &name)
Start timing a region using the default RegionTimer.
DEPRECATED void reset(const char *=0)
Stop timing the current region, if active.
Timer(const Ref< RegionTimer > &)
Construct a Timer object using the giving RegionTimer, but do not begin timing a region.
Timer(const char *name)
Start timing a region using the default RegionTimer and activate the timer.
Timer(const Ref< RegionTimer > &, const std::string &name)
Start timing a region using the given RegionTimer.
void exit(const char *region=0)
Exit the current timing region.
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.
void enter(const char *region)
Begin timing, using the given timing region name.
Timer(const Ref< RegionTimer > &, const char *name)
Start timing a region using the given RegionTimer.
Contains all MPQC code up to version 3.
Definition mpqcin.h:14