main page
modules
namespaces
classes
files
Gecode home
Generated on
for Gecode by
doxygen
1.17.0
gecode
support
timer.hpp
Go to the documentation of this file.
1
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
/*
3
* Main authors:
4
* Mikael Zayenz Lagerkvist <lagerkvist@gecode.dev>
5
*
6
* Copyright:
7
* Mikael Zayenz Lagerkvist, 2009
8
*
9
* This file is part of Gecode, the generic constraint
10
* development environment:
11
* http://www.gecode.dev
12
*
13
* Permission is hereby granted, free of charge, to any person obtaining
14
* a copy of this software and associated documentation files (the
15
* "Software"), to deal in the Software without restriction, including
16
* without limitation the rights to use, copy, modify, merge, publish,
17
* distribute, sublicense, and/or sell copies of the Software, and to
18
* permit persons to whom the Software is furnished to do so, subject to
19
* the following conditions:
20
*
21
* The above copyright notice and this permission notice shall be
22
* included in all copies or substantial portions of the Software.
23
*
24
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31
*
32
*/
33
34
#include <chrono>
35
36
namespace
Gecode
{
namespace
Support
{
37
45
class
GECODE_SUPPORT_EXPORT
Timer
{
46
private
:
47
using
time_point = std::chrono::time_point<std::chrono::steady_clock>;
48
time_point t0;
49
50
public
:
52
void
start
(
void
);
54
double
stop
(
void
);
55
};
56
57
inline
void
58
Timer::start
(
void
) {
59
t0 = std::chrono::steady_clock::now();
60
}
61
62
inline
double
63
Timer::stop
(
void
) {
64
std::chrono::duration<double, std::milli> duration = std::chrono::steady_clock::now() - t0;
65
return
duration.count();
66
}
67
68
}}
69
70
// STATISTICS: support-any
Gecode::Support::Timer
Timer
Definition
timer.hpp:45
Gecode::Support::Timer::stop
double stop(void)
Get time since start of timer.
Definition
timer.hpp:63
Gecode::Support::Timer::start
void start(void)
Start timer.
Definition
timer.hpp:58
Gecode::Support
Support algorithms and datastructures
Gecode
Gecode toplevel namespace
GECODE_SUPPORT_EXPORT
#define GECODE_SUPPORT_EXPORT
Definition
support.hh:75