DOLFINx 0.10.0.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 <chrono>
12#include <map>
13#include <mpi.h>
14#include <string>
15#include <utility>
16
17namespace dolfinx::common
18{
24{
25public:
28 static TimeLogger& instance();
29
31 void register_timing(std::string task,
32 std::chrono::duration<double, std::ratio<1>> wall);
33
35 Table timing_table() const;
36
41 void list_timings(MPI_Comm comm, Table::Reduction reduction) const;
42
46 std::pair<int, std::chrono::duration<double, std::ratio<1>>>
47 timing(std::string task) const;
48
51 std::map<std::string,
52 std::pair<int, std::chrono::duration<double, std::ratio<1>>>>
53 timings() const;
54
55private:
57 TimeLogger() = default;
58
59 // This class is used as a singleton and thus should not allow copies.
60 TimeLogger(const TimeLogger&) = delete;
61
62 // This class is used as a singleton and thus should not allow copies.
63 TimeLogger& operator=(const TimeLogger&) = delete;
64
66 ~TimeLogger() = default;
67
68 // List of timings for tasks, map from string to (num_timings,
69 // total_wall_time)
70 std::map<std::string,
71 std::pair<int, std::chrono::duration<double, std::ratio<1>>>>
72 _timings;
73};
74} // namespace dolfinx::common
This class provides storage and pretty-printing for tables.
Definition Table.h:28
Reduction
Definition Table.h:33
Time logger maintaining data collected by Timer, if registered.
Definition TimeLogger.h:24
std::pair< int, std::chrono::duration< double, std::ratio< 1 > > > timing(std::string task) const
Return timing.
Definition TimeLogger.cpp:70
std::map< std::string, std::pair< int, std::chrono::duration< double, std::ratio< 1 > > > > timings() const
Logged elapsed times.
Definition TimeLogger.cpp:85
void list_timings(MPI_Comm comm, Table::Reduction reduction) const
Definition TimeLogger.cpp:41
void register_timing(std::string task, std::chrono::duration< double, std::ratio< 1 > > wall)
Register timing (for later summary)
Definition TimeLogger.cpp:23
Table timing_table() const
Return a summary of timings and tasks in a Table.
Definition TimeLogger.cpp:53
static TimeLogger & instance()
Singleton access.
Definition TimeLogger.cpp:16
Miscellaneous classes, functions and types.
Definition dolfinx_common.h:8