Arcane
v4.1.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
Profiler.cc
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
/* Profiler.cc (C) 2000-2026 */
9
/* */
10
/* Classes utilitaires. */
11
/*---------------------------------------------------------------------------*/
12
/*---------------------------------------------------------------------------*/
13
14
#include "arccore/alina/Profiler.h"
15
16
#include "arcane/utils/PlatformUtils.h"
17
18
/*---------------------------------------------------------------------------*/
19
/*---------------------------------------------------------------------------*/
20
21
namespace
Arcane::Alina
22
{
23
Profiler
global_alina_profiler;
24
25
Profiler
& Profiler::
26
globalProfiler()
27
{
28
return
global_alina_profiler;
29
}
30
31
void
Profiler::
32
globalTic(
const
std::string& name)
33
{
34
global_alina_profiler.
tic
(name);
35
}
36
37
Profiler::delta_type
Profiler::
38
globalToc
(
const
std::string&)
39
{
40
return
global_alina_profiler.toc();
41
}
42
43
/*---------------------------------------------------------------------------*/
44
/*---------------------------------------------------------------------------*/
45
46
void
Profiler::
47
tic
(
const
std::string& name)
48
{
49
stack.back()->children[name].begin =
Platform::getRealTime
();
50
stack.push_back(&stack.back()->children[name]);
51
}
52
53
/*---------------------------------------------------------------------------*/
54
/*---------------------------------------------------------------------------*/
55
56
Profiler::delta_type
Profiler::
57
toc
(
const
std::string&)
58
{
59
profile_unit
* top = stack.back();
60
stack.pop_back();
61
62
value_type current =
Platform::getRealTime
();
63
delta_type delta = current - top->begin;
64
65
top->length += delta;
66
root.length = current - root.begin;
67
68
return
delta;
69
}
70
71
/*---------------------------------------------------------------------------*/
72
/*---------------------------------------------------------------------------*/
73
74
void
Profiler::
75
reset()
76
{
77
stack.clear();
78
root.length = 0;
79
root.children.clear();
80
81
stack.push_back(&root);
82
root.begin =
Platform::getRealTime
();
83
;
84
}
85
86
/*---------------------------------------------------------------------------*/
87
/*---------------------------------------------------------------------------*/
88
void
Profiler::
89
init()
90
{
91
stack.reserve(128);
92
stack.push_back(&root);
93
root.begin =
Platform::getRealTime
();
94
}
95
96
/*---------------------------------------------------------------------------*/
97
/*---------------------------------------------------------------------------*/
98
99
void
Profiler::
100
print(std::ostream& out)
const
101
{
102
if
(stack.back() != &root)
103
out <<
"Warning! Profile is incomplete."
<< std::endl;
104
ScopedStreamModifier ss(out);
105
root.print(out, name, 0, root.length, root.total_width(name, 0));
106
}
107
108
/*---------------------------------------------------------------------------*/
109
/*---------------------------------------------------------------------------*/
110
111
}
// namespace Arcane::Alina
112
113
/*---------------------------------------------------------------------------*/
114
/*---------------------------------------------------------------------------*/
Arcane::Alina::Profiler
Profiler class.
Definition
Profiler.h:50
Arcane::Alina::Profiler::globalToc
static delta_type globalToc(const std::string &="")
Stops measurement.
Definition
Profiler.cc:38
Arcane::Alina::Profiler::tic
void tic(const std::string &name)
Starts measurement.
Definition
Profiler.cc:47
Arcane::Alina::Profiler::toc
delta_type toc(const std::string &="")
Stops measurement.
Definition
Profiler.cc:57
Arcane::Platform::getRealTime
ARCCORE_BASE_EXPORT Real getRealTime()
Temps Real utilisé en secondes.
Definition
arccore/src/base/arccore/base/PlatformUtils.cc:600
Arcane::Alina::Profiler::profile_unit
Definition
Profiler.h:124
arccore
src
alina
arccore
alina
Profiler.cc
Généré le Lundi 20 Avril 2026 04:40:06 pour Arcane par
1.13.2