Cadabra
Computer algebra system for field theory problems
Toggle main menu visibility
Loading...
Searching...
No Matches
core
Stopwatch.hh
Go to the documentation of this file.
1
/*
2
3
Cadabra: a field-theory motivated computer algebra system.
4
Copyright (C) 2001-2011 Kasper Peeters <kasper.peeters@aei.mpg.de>
5
6
This program is free software: you can redistribute it and/or
7
modify it under the terms of the GNU General Public License as
8
published by the Free Software Foundation, either version 3 of the
9
License, or (at your option) any later version.
10
11
This program 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 GNU
14
General Public License for more details.
15
16
You should have received a copy of the GNU General Public License
17
along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19
*/
20
21
#ifndef stopwatch_hh__
22
#define stopwatch_hh__
23
24
#include <chrono>
25
#include <iosfwd>
26
#include <iostream>
27
106
107
class
Stopwatch
{
108
public
:
109
Stopwatch
();
110
111
typedef
std::chrono::steady_clock
clock
;
112
114
void
reset
();
116
void
start
();
118
void
stop
();
120
long
seconds
()
const
;
122
long
useconds
()
const
;
124
bool
stopped
()
const
;
125
126
friend
std::ostream&
operator<<
(std::ostream&,
const
Stopwatch
&);
127
128
Stopwatch
&
operator/=
(
int
);
129
130
private
:
131
void
checkpoint_
()
const
;
132
133
mutable
clock::time_point
start_
;
134
mutable
long
elapsed_
;
135
bool
stopped_
;
136
137
static
const
long
s_to_us
= 1000000L;
138
};
139
141
std::ostream&
operator<<
(std::ostream&,
const
Stopwatch
&);
142
143
#endif
Stopwatch
The Stopwach class provides a simple interace to allow timing function calls etc.....
Definition
Stopwatch.hh:107
Stopwatch::useconds
long useconds() const
Number of micro-seconds elapsed (needs to be added to 'seconds').
Definition
Stopwatch.cc:66
Stopwatch::elapsed_
long elapsed_
Definition
Stopwatch.hh:134
Stopwatch::clock
std::chrono::steady_clock clock
Definition
Stopwatch.hh:111
Stopwatch::operator/=
Stopwatch & operator/=(int)
Definition
Stopwatch.cc:72
Stopwatch::reset
void reset()
Reset to no-time-elapsed.
Definition
Stopwatch.cc:29
Stopwatch::stopped
bool stopped() const
Is the stopwatch currently timing?
Definition
Stopwatch.cc:47
Stopwatch::Stopwatch
Stopwatch()
Definition
Stopwatch.cc:24
Stopwatch::checkpoint_
void checkpoint_() const
Definition
Stopwatch.cc:52
Stopwatch::start
void start()
Continue timing (does not reset).
Definition
Stopwatch.cc:35
Stopwatch::operator<<
friend std::ostream & operator<<(std::ostream &, const Stopwatch &)
Print human-readable representation of the time elapsed.
Definition
Stopwatch.cc:78
Stopwatch::stopped_
bool stopped_
Definition
Stopwatch.hh:135
Stopwatch::start_
clock::time_point start_
Definition
Stopwatch.hh:133
Stopwatch::stop
void stop()
Stop timing.
Definition
Stopwatch.cc:41
Stopwatch::seconds
long seconds() const
Number of seconds elapsed.
Definition
Stopwatch.cc:60
Stopwatch::s_to_us
static const long s_to_us
Definition
Stopwatch.hh:137
operator<<
std::ostream & operator<<(std::ostream &os, const cadabra::Adjform &adjform)
Definition
Adjform.cc:644
Generated by
1.18.0