diff options
| author | Carl Hetherington <cth@carlh.net> | 2019-03-26 14:58:43 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2019-05-10 23:43:42 +0100 |
| commit | b7e546d9685c0a3304faa48e95516915d811ec5c (patch) | |
| tree | 678ca0c95d70e291d25216384cde942b4bbfca10 /src/lib/timer.h | |
| parent | f9361d461d2137953a492a2d424ef9df757290d4 (diff) | |
Add some very basic timing of the player.
Diffstat (limited to 'src/lib/timer.h')
| -rw-r--r-- | src/lib/timer.h | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/src/lib/timer.h b/src/lib/timer.h index 9ea95c720..bd4e652f8 100644 --- a/src/lib/timer.h +++ b/src/lib/timer.h @@ -1,6 +1,6 @@ /* - Copyright (C) 2012 Carl Hetherington <cth@carlh.net> - Copyright (C) 2000-2007 Paul Davis + Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net> + This file is part of DCP-o-matic. DCP-o-matic is free software; you can redistribute it and/or modify @@ -26,6 +26,7 @@ #define DCPOMATIC_TIMER_H #include <sys/time.h> +#include <boost/optional.hpp> #include <string> #include <map> @@ -59,20 +60,44 @@ private: class StateTimer { public: + explicit StateTimer (std::string n); StateTimer (std::string n, std::string s); ~StateTimer (); - void set_state (std::string s); + void set (std::string s); + void unset (); + + std::string name () const { + return _name; + } + + class Counts + { + public: + Counts () + : total_time (0) + , number (0) + {} + + double total_time; + int number; + }; + + std::map<std::string, Counts> counts () const { + return _counts; + } private: + void set_internal (boost::optional<std::string> s); + /** name to add to the output */ std::string _name; /** current state */ - std::string _state; + boost::optional<std::string> _state; /** time that _state was entered */ double _time; - /** time that has been spent in each state so far */ - std::map<std::string, double> _totals; + /** total time and number of entries for each state */ + std::map<std::string, Counts> _counts; }; #endif |
