From 5a3f9a5595077f9c9886955cf0d5fc9a2e1512fb Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 26 Mar 2019 14:58:43 +0000 Subject: Add some very basic timing of the player. --- src/lib/timer.h | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'src/lib/timer.h') 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 - Copyright (C) 2000-2007 Paul Davis + Copyright (C) 2012-2019 Carl Hetherington + 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 +#include #include #include @@ -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 counts () const { + return _counts; + } private: + void set_internal (boost::optional s); + /** name to add to the output */ std::string _name; /** current state */ - std::string _state; + boost::optional _state; /** time that _state was entered */ double _time; - /** time that has been spent in each state so far */ - std::map _totals; + /** total time and number of entries for each state */ + std::map _counts; }; #endif -- cgit v1.2.3