teditor  1.8.0@@fee5e94
Terminal based editor written in C++
timer.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <stdint.h>
4 #include <unordered_map>
5 #include <chrono>
6 #include <string>
7 
8 namespace teditor {
9 
13 class Timer {
14  public:
15  Timer() : running(false) {}
16  void start();
17  bool isRunning() const { return running; }
18  void stop();
19  double elapsed();
20 
21  private:
22  bool running;
23  std::chrono::steady_clock::time_point start_;
24  std::chrono::steady_clock::time_point stop_;
25 }; // class Timer
26 
27 typedef std::unordered_map<std::string, Timer> Timers;
28 
30 Timer& getTimer(const std::string& name);
31 
33 void tic(const std::string& name);
34 
36 void toc(const std::string& name);
37 
39 void resetTimers();
40 
41 } // namespace teditor
teditor::Timer
Main object used for timing event.
Definition: timer.h:13
teditor::Timer::elapsed
double elapsed()
Definition: timer.cpp:18
utils.h
teditor::Timer::start
void start()
Definition: timer.cpp:6
timer.h
teditor::getTimers
Timers & getTimers()
Definition: timer.cpp:23
teditor::Timer::stop
void stop()
Definition: timer.cpp:12
teditor::tic
void tic(const std::string &name)
Definition: timer.cpp:35
teditor::getTimer
Timer & getTimer(const std::string &name)
Definition: timer.cpp:28
ASSERT
#define ASSERT(check, fmt,...)
Macro to assert with runtime_error exception if the check fails.
Definition: utils.h:35
teditor::resetTimers
void resetTimers()
Definition: timer.cpp:50
teditor::Timers
std::unordered_map< std::string, Timer > Timers
Definition: timer.h:27
teditor::toc
void toc(const std::string &name)
Definition: timer.cpp:45
teditor::Timer::Timer
Timer()
Definition: timer.h:15
teditor::Timer::isRunning
bool isRunning() const
Definition: timer.h:17
teditor
Definition: any.hpp:10