OGS
CPUTime.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <ctime>
7
8namespace BaseLib
9{
12{
13public:
15 void start() { start_time_ = clock(); }
16
18 double elapsed() const
19 {
20 return (clock() - start_time_) / static_cast<double>(CLOCKS_PER_SEC);
21 }
22
23private:
24 double start_time_ = 0.;
25};
26
27} // end namespace BaseLib
Count CPU time.
Definition CPUTime.h:12
void start()
Start the timer.
Definition CPUTime.h:15
double start_time_
Definition CPUTime.h:24
double elapsed() const
Get the elapsed time after started.
Definition CPUTime.h:18