DOLFINx 0.9.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 <optional>
12#include <string>
13
14namespace dolfinx::common
15{
16
30
31class Timer
32{
33public:
38 Timer(std::optional<std::string> task = std::nullopt);
39
41 ~Timer();
42
44 void start();
45
47 void resume();
48
51 double stop();
52
54 std::array<double, 3> elapsed() const;
55
56private:
57 // Name of task
58 std::optional<std::string> _task;
59
60 // Implementation of timer
61 boost::timer::cpu_timer _timer;
62};
63} // namespace dolfinx::common
Definition Timer.h:32
double stop()
Definition Timer.cpp:38
void resume()
Resume timer. Not well-defined for logging timer.
Definition Timer.cpp:27
~Timer()
Destructor.
Definition Timer.cpp:19
void start()
Zero and start timer.
Definition Timer.cpp:25
std::array< double, 3 > elapsed() const
Return wall, user and system time in seconds.
Definition Timer.cpp:47
Timer(std::optional< std::string > task=std::nullopt)
Definition Timer.cpp:17
Miscellaneous classes, functions and types.
Definition dolfinx_common.h:8