STK++ 0.9.13
STK_Chrono.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------*/
2/* Copyright (C) 2004-2016 Serge Iovleff, Université Lille 1, Inria
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this program; if not, write to the
16 Free Software Foundation, Inc.,
17 59 Temple Place,
18 Suite 330,
19 Boston, MA 02111-1307
20 USA
21
22 Contact : S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
23*/
24
25/*
26 * Project: STKernel::Base
27 * Purpose: Utility for computing elapsed time.
28 * Author: Serge Iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
29 *
30 **/
31
37
38
39#ifndef STK_CHRONO_H
40#define STK_CHRONO_H
41
42#include <chrono>
43
44namespace STK
45{
50namespace Chrono
51{
53 static std::chrono::steady_clock::time_point t_start;
55 static std::chrono::steady_clock::time_point t_end;
58 inline void start() { t_start = std::chrono::steady_clock::now(); }
63 inline Real elapsed()
64 {
65 t_end = std::chrono::steady_clock::now();
66 return std::chrono::duration<Real>(t_end - t_start).count();
67 }
68
69} // namespace Chrono
70
71} // namespace STK
72#endif /*STK_CHRONO_H*/
Real elapsed()
Compute the elapsed time (in second) since last start() call.
Definition STK_Chrono.h:63
void start()
Start the Chrono.
Definition STK_Chrono.h:58
double Real
STK fundamental type of Real values.
The namespace Chrono is an utility namespace for computing elapsed wall-clock time during the executi...
Definition STK_Chrono.h:51
The namespace STK is the main domain space of the Statistical ToolKit project.