2 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
3 Copyright (C) 2000-2007 Paul Davis
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 * @brief Some timing classes for debugging and profiling.
25 #ifndef DCPOMATIC_TIMER_H
26 #define DCPOMATIC_TIMER_H
32 /** @class PeriodTimer
33 * @brief A class to allow timing of a period within the caller.
35 * On destruction, it will output the time since its construction.
40 PeriodTimer (std::string n);
45 /** name to use when giving output */
47 /** time that this class was constructed */
48 struct timeval _start;
52 * @brief A class to allow measurement of the amount of time a program
53 * spends in one of a set of states.
55 * Once constructed, the caller can call set_state() whenever
56 * its state changes. When StateTimer is destroyed, it will
57 * output (to cout) a summary of the time spent in each state.
62 StateTimer (std::string n, std::string s);
65 void set_state (std::string s);
68 /** name to add to the output */
72 /** time that _state was entered */
74 /** time that has been spent in each state so far */
75 std::map<std::string, double> _totals;