feisty meow concerns codebase
2.140
stopwatch.h
Go to the documentation of this file.
1
#ifndef STOPWATCH_CLASS
2
#define STOPWATCH_CLASS
3
4
/*
5
* Name : stopwatch
6
* Author : Chris Koeritz
7
*
8
* Copyright (c) 1991-$now By Author. This program is free software; you can
9
* redistribute it and/or modify it under the terms of the GNU General Public
10
* License as published by the Free Software Foundation; either version 2 of
11
* the License or (at your option) any later version. This is online at:
12
* http://www.fsf.org/copyleft/gpl.html
13
* Please send any updates to: fred@gruntose.com
14
*/
15
16
#include "
time_stamp.h
"
17
18
namespace
timely
{
19
21
28
class
stopwatch
:
public
virtual
basis::root_object
29
{
30
public
:
31
stopwatch
();
32
stopwatch
(
const
stopwatch
&to_copy);
33
34
virtual
~stopwatch
();
35
36
stopwatch
&
operator =
(
const
stopwatch
&to_copy);
37
38
void
start
();
40
42
void
halt
();
44
46
void
stop
() {
halt
(); }
48
49
void
reset
();
51
52
int
milliseconds
();
54
int
elapsed
() {
return
milliseconds
(); }
56
57
private
:
58
enum
stopwatch_kinds { UNSTARTED, RUNNING, STOPPED };
59
stopwatch_kinds _status;
60
time_stamp *_start_time;
61
time_stamp *_stop_time;
62
int
_total_so_far;
63
64
int
common_measure();
66
67
int
compute_diff(
const
time_stamp &t1,
const
time_stamp &t2);
69
};
70
72
74
79
#define TIME_CHECK_BEGIN \
80
stopwatch t; \
81
t.start();
82
#define TIME_CHECK_END(logger, who, msec_limit, what, filter) { \
83
t.halt(); \
84
if (t.milliseconds() > msec_limit) { \
85
(logger).log( a_sprintf("TIME_CHECK: %s: %d ms wait for %s.", \
86
(who), t.milliseconds(), (what)), filter); \
87
} \
88
}
89
90
}
//namespace.
91
92
#endif
93
timely::stopwatch
A class for measuring event durations in real time.
Definition
stopwatch.h:29
timely::stopwatch::operator=
stopwatch & operator=(const stopwatch &to_copy)
Definition
stopwatch.cpp:47
timely::stopwatch::milliseconds
int milliseconds()
Returns the elapsed number of milliseconds on the stopwatch, overall.
Definition
stopwatch.cpp:59
timely::stopwatch::halt
void halt()
Stops the timing.
Definition
stopwatch.cpp:71
timely::stopwatch::stopwatch
stopwatch()
Definition
stopwatch.cpp:26
timely::stopwatch::reset
void reset()
Stops the stopwatch and clears it to zero time elapsed.
Definition
stopwatch.cpp:57
timely::stopwatch::stop
void stop()
a synonym for halt().
Definition
stopwatch.h:46
timely::stopwatch::elapsed
int elapsed()
a synonym for milliseconds().
Definition
stopwatch.h:54
timely::stopwatch::~stopwatch
virtual ~stopwatch()
Definition
stopwatch.cpp:40
timely::stopwatch::start
void start()
Begins the timing.
Definition
stopwatch.cpp:61
timely
#include <time.h>
Definition
earth_time.cpp:37
time_stamp.h
nucleus
library
timely
stopwatch.h
Generated by
1.9.8