SimulationCraft
SimulationCraft is a tool to explore combat mechanics in the popular MMO RPG World of Warcraft (tm).
report_timer.hpp
1 // ==========================================================================
2 // Dedmonwakeen's Raid DPS/TPS Simulator.
3 // Send questions to [email protected]
4 // ==========================================================================
5 
6 #pragma once
7 
8 #include "lib/fmt/ostream.h"
9 #include "util/chrono.hpp"
10 
11 #include <iosfwd>
12 #include <string>
13 
19 {
20 private:
21  std::string title;
22  std::FILE* out;
23  chrono::wall_clock::time_point start_time;
24  bool started;
25 
26 public:
27  report_timer_t( std::string title, std::FILE* out ) : title( std::move( title ) ), out( out ), started( false )
28  {
29  }
30 
31  void start()
32  {
33  start_time = chrono::wall_clock::now();
34  started = true;
35  }
36 
38  {
39  if ( started )
40  {
41  fmt::print( out, "{} took {}seconds.\n", title, chrono::elapsed_fp_seconds( start_time ) );
42  }
43  }
44 };
Automatic Timer reporting the time between construction and desctruction of the object.
Definition: report_timer.hpp:18