DOLFINx 0.8.0
DOLFINx C++ interface
Loading...
Searching...
No Matches
Timer.h
1// Copyright (C) 2008 Anders Logg, 2015 Jan Blechta
2//
3// This file is part of DOLFINx (https://www.fenicsproject.org)
4//
5// SPDX-License-Identifier: LGPL-3.0-or-later
6
7#pragma once
8
9#include <array>
10#include <boost/timer/timer.hpp>
11#include <string>
12
13namespace dolfinx::common
14{
15
29
30class Timer
31{
32public:
34 Timer();
35
37 Timer(const std::string& task);
38
40 ~Timer();
41
43 void start();
44
46 void resume();
47
50 double stop();
51
53 std::array<double, 3> elapsed() const;
54
55private:
56 // Name of task
57 std::string _task;
58
59 // Implementation of timer
60 boost::timer::cpu_timer _timer;
61};
62} // namespace dolfinx::common
Definition Timer.h:31
double stop()
Definition Timer.cpp:45
void resume()
Resume timer. Not well-defined for logging timer.
Definition Timer.cpp:34
~Timer()
Destructor.
Definition Timer.cpp:26
void start()
Zero and start timer.
Definition Timer.cpp:32
Timer()
Create timer without logging.
Definition Timer.cpp:16
std::array< double, 3 > elapsed() const
Return wall, user and system time in seconds.
Definition Timer.cpp:54
Miscellaneous classes, functions and types.
Definition dolfinx_common.h:8