Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
ITimeStats.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* ITimeStats.h (C) 2000-2025 */
9/* */
10/* Interface managing execution time statistics. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_ITIMESTATS_H
13#define ARCANE_CORE_ITIMESTATS_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24class Properties;
25class Timer;
26class JSONWriter;
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31/*!
32 * \internal
33 * \brief Interface managing execution time statistics.
34 *
35 * You must call beginGatherStats() to start collecting the
36 * information and call endGatherStats() to stop the collection.
37 *
38 * Generally, this interface is not used directly but through
39 * the Timer::Phase and Timer::Action classes.
40 *
41 * The methods of this class must only be called by a single thread.
42 */
44{
45 public:
46
47 // Releases resources.
48 virtual ~ITimeStats() = default;
49
50 public:
51
52 //! Starts time collection
53 virtual void beginGatherStats() = 0;
54 //! Stops time collection
55 virtual void endGatherStats() = 0;
56
57 public:
58
59 virtual void beginAction(const String& action_name) = 0;
60 virtual void endAction(const String& action_name, bool print_time) = 0;
61
62 virtual void beginPhase(eTimePhase phase) = 0;
63 virtual void endPhase(eTimePhase phase) = 0;
64
65 public:
66
67 /*!
68 * \brief Real elapsed time for phase \a phase
69 *
70 * Returns the real elapsed time (in seconds) for phase \a phase.
71 */
72 virtual Real elapsedTime(eTimePhase phase) = 0;
73
74 /*!
75 * \brief Elapsed time for a phase of an action.
76 *
77 * Returns the real elapsed time (in seconds) for phase \a phase
78 * of action \a action. The returned time includes that of the action and
79 * all of its children.
80 */
81 virtual Real elapsedTime(eTimePhase phase, const String& action) = 0;
82
83 /*!
84 * \brief Displays statistics for an action.
85 *
86 * Displays the statistics for action \a name as well as its sub-actions
87 * for the current iteration.
88 */
89 virtual void dumpCurrentStats(const String& name) = 0;
90
91 public:
92
93 /*!
94 * \brief Displays execution time statistics.
95 *
96 * It is possible to specify a value to get a time
97 * per iteration or per entity. If \a use_elapsed_time is true,
98 * it uses clock time; otherwise, it uses CPU time.
99 */
100 virtual void dumpStats(std::ostream& ostr, bool is_verbose, Real nb,
101 const String& name, bool use_elapsed_time = false) = 0;
102
103 /*!
104 * \brief Displays the current date and memory consumption.
105 *
106 * This operation is collective on \a pm.
107 *
108 * This operation displays the memory consumed for the current subdomain
109 * as well as the min and max for all subdomains.
110 */
112
113 /*!
114 * \brief Indicates if statistics are active.
115 *
116 * Statistics are active between the call to beginGatherStats()
117 * and endGatherStats().
118 */
119 virtual bool isGathering() const = 0;
120
121 //! Serializes the temporal statistics into the writer \a writer.
122 virtual void dumpStatsJSON(JSONWriter& writer) = 0;
123
124 //! Associated collection interface
125 virtual ITimeMetricCollector* metricCollector() = 0;
126
127 /*!
128 * \brief Notifies that a new iteration of the calculation loop begins.
129 *
130 * This information is used to calculate times per iteration.
131 */
132 virtual void notifyNewIterationLoop() = 0;
133 virtual void saveTimeValues(Properties* p) = 0;
134 virtual void mergeTimeValues(Properties* p) = 0;
135
136 /*
137 * \brief Resets the current statistics for an action and its sub-actions
138 *
139 * Resets the statistics for action \a action_name and its
140 * sub-actions. If no action named \a action_name exists, it does nothing.
141 *
142 * This method is reserved for testing and should not be used
143 * outside of this configuration to avoid invalidating the
144 * temporal statistics.
145 */
146 virtual void resetStats(const String& action_name) = 0;
147};
148
149/*---------------------------------------------------------------------------*/
150/*---------------------------------------------------------------------------*/
151
152} // End namespace Arcane
153
154/*---------------------------------------------------------------------------*/
155/*---------------------------------------------------------------------------*/
156
157#endif
Declarations of Arcane's general types.
Interface of the parallelism manager for a subdomain.
virtual Real elapsedTime(eTimePhase phase)=0
Real elapsed time for phase phase.
virtual void dumpTimeAndMemoryUsage(IParallelMng *pm)=0
Displays the current date and memory consumption.
virtual void dumpCurrentStats(const String &name)=0
Displays statistics for an action.
virtual void endGatherStats()=0
Stops time collection.
virtual void beginGatherStats()=0
Starts time collection.
virtual ITimeMetricCollector * metricCollector()=0
Associated collection interface.
virtual void dumpStats(std::ostream &ostr, bool is_verbose, Real nb, const String &name, bool use_elapsed_time=false)=0
Displays execution time statistics.
virtual bool isGathering() const =0
Indicates if statistics are active.
virtual void notifyNewIterationLoop()=0
Notifies that a new iteration of the calculation loop begins.
virtual Real elapsedTime(eTimePhase phase, const String &action)=0
Elapsed time for a phase of an action.
virtual void dumpStatsJSON(JSONWriter &writer)=0
Serializes the temporal statistics into the writer writer.
List of properties.
Definition Properties.h:65
Management of a timer.
Definition Timer.h:63
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
double Real
Type representing a real number.
eTimePhase
Phase of a temporal action.