MinLCA algorithms
profiler.hh
Go to the documentation of this file.
1 #ifndef __MINLCA_MINLCA_PROFILER_HH
2 #define __MINLCA_MINLCA_PROFILER_HH
3 
4 #include <type_traits>
5 #include <minlca/base.hh>
6 #include <utils/timer.hh>
7 
10 
11 namespace minlca
12 {
13 
15 template<class LCA>
16 class MinLCAProfiler : public LCA
17 {
18 protected:
19  typedef LCA Base;
21  double _creation_time;
22  double _init_time;
23  double _run_time;
24 
25 public:
27  template<typename... Args>
29  Args &&...
30  args
31  )
32  : Base(std::forward<Args>(args)...)
33  {
34  _creation_time = _t.elapsed();
35  }
36 
38  template<typename... Args>
39  void init(
40  Args &&...
41  args
42  )
43  {
44  _t.restart();
45  Base::init(std::forward<Args>(args)...);
46  _init_time = _t.elapsed();
47  }
48 
50  virtual MinLCAStatus run()
51  {
52  _t.restart();
53  MinLCAStatus result = Base::run();
54  _run_time = _t.elapsed();
55 
56  return result;
57  }
58 
62  double runTime()
63  {
64  return _run_time;
65  }
66 
70  double initTime()
71  {
72  return _init_time;
73  }
74 
78  double creationTime()
79  {
80  return _creation_time;
81  }
82 };
83 }
84 
85 #endif
double runTime()
Retrieve the duration of running the algorithm.
Definition: profiler.hh:62
double _run_time
Duration of algorithm running.
Definition: profiler.hh:23
virtual MinLCAStatus run()
Run the algorithm.
Definition: profiler.hh:50
MinLCAStatus
Possible status for MinLCA solution.
Definition: base.hh:20
Default namespace Default namespace for MinLCA algorithms.
Definition: base.hh:15
Defines the base class for MinLCA algorithms.
utils::Timer _t
Timer used to count the durations.
Definition: profiler.hh:20
Class for timing MinLCA algorithms.
Definition: profiler.hh:16
double initTime()
Retrieve the duration of initialising the algorithm.
Definition: profiler.hh:70
Description of Timer.
double _creation_time
Duration of object creation.
Definition: profiler.hh:21
Simple timing class.
Definition: timer.hh:14
double creationTime()
Retrieve the duration of instantiating the algorithm class.
Definition: profiler.hh:78
double elapsed() const
Retrieve elapsed time.
Definition: timer.cc:20
void restart()
Restart the timer.
Definition: timer.cc:15
void init(Args &&...args)
Reset the data structures of the algorithm.
Definition: profiler.hh:39
MinLCAProfiler(Args &&...args)
Constructor.
Definition: profiler.hh:28
double _init_time
Duration of algorithm initialisation.
Definition: profiler.hh:22