Finite Volume Solver  prototype
A framework to build finite volume solvers for the AG Klein at the Freie Universität Berlin.
Timer.hpp
Go to the documentation of this file.
1 //
2 // Created by Patrick Denzler on 10.10.19.
3 //
4 
5 #ifndef FUB_EXT_TIMER_HPP
6 #define FUB_EXT_TIMER_HPP
7 
8 #include <chrono>
9 #include <functional>
10 #include <string>
11 
12 namespace fub {
13 
14 class Timer {
15 public:
16  Timer(String name);
17  void Start();
18  void Stop();
19  void Measure(F&& function, Args&&... args);
20  void Print();
21 
22 private:
23  String name_;
24  std::chrono::time_point start_time_;
25  std::chrono::time_point stop_time_;
26 };
27 
28 template <typename F, typename... Args>
29 void Timer::Measure(F&& function, Args&&... args) {
30  this->Start();
31  std::invoke(function, args...);
32  this->Stop();
33 }
34 
35 } // namespace fub
36 
37 #endif // FUB_EXT_TIMER_HPP
Definition: Timer.hpp:14
void Measure(F &&function, Args &&... args)
Definition: Timer.hpp:29
Timer(String name)
std::chrono::time_point stop_time_
Definition: Timer.hpp:25
void Print()
void Stop()
String name_
Definition: Timer.hpp:23
std::chrono::time_point start_time_
Definition: Timer.hpp:24
void Start()
The fub namespace.
Definition: AnyBoundaryCondition.hpp:31