Arcane  4.2.3.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
IProfilingService.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/* IProfilingService.h (C) 2000-2026 */
9/* */
10/* Interface d'un service de profiling. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_UTILS_IPROFILINGSERVICE_H
13#define ARCANE_UTILS_IPROFILINGSERVICE_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28class ITimerMng;
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
44class ARCANE_UTILS_EXPORT IProfilingService
45{
46 public:
47
48 virtual ~IProfilingService() = default;
49
50 public:
51
57 virtual void initialize() = 0;
58
60 virtual bool isInitialized() const { return false; }
61
63 virtual void startProfiling() = 0;
64
65 virtual void switchEvent() = 0;
66
68 virtual void stopProfiling() = 0;
69
76 virtual bool isRunning() const =0;
77
85 virtual void printInfos(bool dump_file = false) = 0;
86
87 virtual void getInfos(Int64Array&) = 0;
88
90 virtual void dumpJSON(JSONWriter& writer) = 0;
91
97 virtual void reset() = 0;
98
100 virtual ITimerMng* timerMng() = 0;
101};
102
103/*---------------------------------------------------------------------------*/
104/*---------------------------------------------------------------------------*/
108class ARCANE_UTILS_EXPORT ProfilingSentry
109{
110 public:
111
112 explicit ProfilingSentry(IProfilingService* s)
113 : m_service(s)
114 {
115 if (m_service)
116 m_service->startProfiling();
117 }
118 ~ProfilingSentry()
119 {
120 if (m_service)
121 m_service->stopProfiling();
122 }
123
124 public:
125
126 IProfilingService* service() { return m_service; }
127
128 private:
129
130 IProfilingService* m_service;
131};
132
133/*---------------------------------------------------------------------------*/
134/*---------------------------------------------------------------------------*/
140class ARCANE_UTILS_EXPORT ProfilingSentryWithInitialize
141{
142 public:
143
150 : m_service(s)
151 {
152 if (m_service) {
153 if (!m_service->isInitialized())
154 m_service->initialize();
155 m_service->startProfiling();
156 }
157 }
158
160 {
161 if (m_service) {
162 m_service->stopProfiling();
163 if (m_print_at_end)
164 m_service->printInfos(false);
165 }
166 }
167
168 public:
169
170 IProfilingService* service() { return m_service; }
172 void setPrintAtEnd(bool v) { m_print_at_end = v; }
173
174 private:
175
176 IProfilingService* m_service = nullptr;
177 bool m_print_at_end = false;
178};
179
180/*---------------------------------------------------------------------------*/
181/*---------------------------------------------------------------------------*/
182
183} // End namespace Arcane
184
185/*---------------------------------------------------------------------------*/
186/*---------------------------------------------------------------------------*/
187
188#endif
Déclarations des types utilisés dans Arcane.
Interface d'un service de profiling.
virtual bool isInitialized() const
Indique si initialize() a déjà été appelé
virtual ITimerMng * timerMng()=0
Timer utilisant les fonctionnalités de ce service si elles existent. Peut être nul.
virtual bool isRunning() const =0
Indique si le profiling est en cours.
virtual void stopProfiling()=0
Stoppe le profiling.
virtual void startProfiling()=0
Démarre un profiling.
virtual void initialize()=0
Initialise le service de profiling.
virtual void dumpJSON(JSONWriter &writer)=0
Ecrit les infos de profiling dans l'écrivain writer.
virtual void reset()=0
Remet à zéro les compteurs.
virtual void printInfos(bool dump_file=false)=0
Affiche les infos de profiling.
Interface d'un gestionnaire de timer.
Definition ITimerMng.h:49
Classe permettant de démarrer et arrêter automatiquement un service.
void setPrintAtEnd(bool v)
Indique si on imprime les résultats à la fin du profiling.
ProfilingSentryWithInitialize(IProfilingService *s)
Construit une instance associée au service s.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Array< Int64 > Int64Array
Tableau dynamique à une dimension d'entiers 64 bits.
Definition UtilsTypes.h:119