DOLFINx 0.9.0
DOLFINx C++ interface
Loading...
Searching...
No Matches
TimeLogger.h
1// Copyright (C) 2003-2016 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 "Table.h"
10#include "timing.h"
11#include <map>
12#include <mpi.h>
13#include <set>
14#include <string>
15#include <tuple>
16
17namespace dolfinx::common
18{
19
21
23{
24public:
26 TimeLogger() = default;
27
28 // This class is used as a singleton and thus should not allow copies.
29 TimeLogger(const TimeLogger&) = delete;
30
31 // This class is used as a singleton and thus should not allow copies.
32 TimeLogger& operator=(const TimeLogger&) = delete;
33
35 ~TimeLogger() = default;
36
38 void register_timing(std::string task, double wall, double user,
39 double system);
40
42 Table timings(std::set<TimingType> type);
43
49 void list_timings(MPI_Comm comm, std::set<TimingType> type,
50 Table::Reduction reduction);
51
56 std::tuple<int, double, double, double> timing(std::string task);
57
58private:
59 // List of timings for tasks, map from string to (num_timings,
60 // total_wall_time, total_user_time, total_system_time)
61 std::map<std::string, std::tuple<int, double, double, double>> _timings;
62};
63} // namespace dolfinx::common
This class provides storage and pretty-printing for tables.
Definition Table.h:28
Reduction
Definition Table.h:33
Timer logging.
Definition TimeLogger.h:23
~TimeLogger()=default
Destructor.
TimeLogger()=default
Constructor.
std::tuple< int, double, double, double > timing(std::string task)
Definition TimeLogger.cpp:92
void list_timings(MPI_Comm comm, std::set< TimingType > type, Table::Reduction reduction)
Definition TimeLogger.cpp:42
Table timings(std::set< TimingType > type)
Return a summary of timings and tasks in a Table.
Definition TimeLogger.cpp:55
void register_timing(std::string task, double wall, double user, double system)
Register timing (for later summary)
Definition TimeLogger.cpp:17
Miscellaneous classes, functions and types.
Definition dolfinx_common.h:8
@ wall
Wall-clock time.
@ system
System (kernel) time.
@ user
User (cpu) time.