DOLFIN-X
DOLFIN-X C++ interface
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 <dolfinx/common/Table.h>
10 #include <dolfinx/common/timing.h>
11 #include <map>
12 #include <memory>
13 #include <mpi.h>
14 #include <ostream>
15 #include <set>
16 #include <string>
17 #include <thread>
18 #include <tuple>
19 
20 namespace dolfinx::common
21 {
22 
24 
26 {
27 public:
29  TimeLogger() = default;
30 
31  // This class is used as a singleton and thus should not allow copies.
32  TimeLogger(const TimeLogger&) = delete;
33 
34  // This class is used as a singleton and thus should not allow copies.
35  TimeLogger& operator=(const TimeLogger&) = delete;
36 
38  ~TimeLogger() = default;
39 
41  void register_timing(std::string task, double wall, double user,
42  double system);
43 
45  Table timings(std::set<TimingType> type);
46 
51  void list_timings(MPI_Comm mpi_comm, std::set<TimingType> type);
52 
57  std::tuple<int, double, double, double> timing(std::string task);
58 
59 private:
60  // List of timings for tasks, map from string to (num_timings,
61  // total_wall_time, total_user_time, total_system_time)
62  std::map<std::string, std::tuple<int, double, double, double>> _timings;
63 };
64 } // namespace dolfinx::common
dolfinx::common::TimeLogger::timing
std::tuple< int, double, double, double > timing(std::string task)
Return timing.
Definition: TimeLogger.cpp:91
dolfinx::common::TimeLogger::timings
Table timings(std::set< TimingType > type)
Return a summary of timings and tasks in a Table.
Definition: TimeLogger.cpp:54
dolfinx::common::TimeLogger::list_timings
void list_timings(MPI_Comm mpi_comm, std::set< TimingType > type)
List a summary of timings and tasks. MPI_AVG reduction is printed.
Definition: TimeLogger.cpp:42
dolfinx::common::TimeLogger::TimeLogger
TimeLogger()=default
Constructor.
dolfinx::Table
This class provides storage and pretty-printing for tables. Example usage:
Definition: Table.h:29
dolfinx::common::TimeLogger::~TimeLogger
~TimeLogger()=default
Destructor.
dolfinx::common
Miscellaneous classes, functions and types.
dolfinx::common::TimeLogger::register_timing
void register_timing(std::string task, double wall, double user, double system)
Register timing (for later summary)
Definition: TimeLogger.cpp:17
dolfinx::common::TimeLogger
Timer logging.
Definition: TimeLogger.h:25