Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
IPerformanceCounterService.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/* IPerformanceCounterService.h (C) 2000-2022 */
9/* */
10/* Interface of a service for accessing performance counters. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_UTILS_IPERFORMANCECOUNTERSERVICE_H
13#define ARCANE_UTILS_IPERFORMANCECOUNTERSERVICE_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28/*!
29 * \brief Interface of a service for accessing performance counters.
30 */
31class ARCANE_UTILS_EXPORT IPerformanceCounterService
32{
33 public:
34
35 //! Minimum size of the view for getCounters()
36 static const int MIN_COUNTER_SIZE = 8;
37
38 public:
39
40 virtual ~IPerformanceCounterService() = default;
41
42 public:
43
44 //! Initializes the service.
45 virtual void initialize() = 0;
46
47 /*!
48 * \brief Starts tracking performance counters.
49 * \pre isStarted()==false.
50 * \post isStarted()==true.
51 */
52 virtual void start() = 0;
53
54 /*!
55 * \brief Stops tracking performance counters.
56 * \pre isStarted()==true.
57 * \post isStarted()==false.
58 */
59 virtual void stop() = 0;
60
61 //! Indicates if the service has started (start() has been called)
62 virtual bool isStarted() const = 0;
63
64 /*!
65 * \brief Retrieves the current values of the counters.
66 *
67 * This method must only be called if isStarted() is true.
68 *
69 * If \a do_substract is \a false, fills \a counters with the
70 * current values of the counters. If \a do_substract is \a true,
71 * fills counters with the difference between the current values and those
72 * in \a counters during the call.
73 *
74 \code
75 * Int64ArrayView counters = ...;
76 * IPerformanceCounterService* p = ...;
77 * p->getCounters(counters,false);
78 * ... // Operation.
79 * p->getCounters(counters,true);
80 * info() << "Nb cycle=" << counters[0].
81 \endcode
82 *
83 * The counter at index 0 is always the number of cycles. \a counters
84 * must have enough elements to provide at least MIN_COUNTER_SIZE counters.
85 *
86 * \retval the number of counters provided.
87 * \pre isStarted()==true
88 */
89 virtual Int32 getCounters(Int64ArrayView counters, bool do_substract) = 0;
90
91 /*!
92 * \brief Value of the counter for the number of CPU cycles.
93 *
94 * \pre isStarted()==true
95 */
96 virtual Int64 getCycles() = 0;
97};
98
99/*---------------------------------------------------------------------------*/
100/*---------------------------------------------------------------------------*/
101
102} // End namespace Arcane
103
104/*---------------------------------------------------------------------------*/
105/*---------------------------------------------------------------------------*/
106
107#endif
Declarations of types used in Arcane.
Interface of a service for accessing performance counters.
virtual bool isStarted() const =0
Indicates if the service has started (start() has been called).
static const int MIN_COUNTER_SIZE
Minimum size of the view for getCounters().
virtual Int32 getCounters(Int64ArrayView counters, bool do_substract)=0
Retrieves the current values of the counters.
virtual void stop()=0
Stops tracking performance counters.
virtual void start()=0
Starts tracking performance counters.
virtual void initialize()=0
Initializes the service.
virtual Int64 getCycles()=0
Value of the counter for the number of CPU cycles.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
ArrayView< Int64 > Int64ArrayView
C equivalent of a 1D array of 64-bit integers.
Definition UtilsTypes.h:451
std::int64_t Int64
Signed integer type of 64 bits.
std::int32_t Int32
Signed integer type of 32 bits.