ATLAS Offline Software
Control
PerformanceMonitoring
PerfMonTests
src
PerfMonTestCpuCruncherAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// PerfMonTestCpuCruncherAlg.cxx
6
// Implementation file for class PerfMonTest::CpuCruncherAlg
7
// Author: S.Binet<binet@cern.ch>
9
10
11
// STL includes
12
#include <chrono>
13
#include <cmath>
14
15
// FrameWork includes
16
#include "Gaudi/Property.h"
17
18
// PerfMonTests includes
19
#include "
PerfMonTestCpuCruncherAlg.h
"
20
21
using namespace
PerfMonTest
;
22
23
24
StatusCode
CpuCruncherAlg::initialize
()
25
{
26
ATH_MSG_INFO
(
"Initializing "
<<
name
() <<
"..."
) ;
27
28
// Random number service
29
m_distribution
= std::normal_distribution<double>(
m_meanCpuTime
,
m_rmsCpuTime
);
30
31
ATH_MSG_INFO
(
"CPU usage configuration: <"
32
<<
m_meanCpuTime
<<
"> +/- "
33
<<
m_rmsCpuTime
<<
" ms"
) ;
34
35
36
return
StatusCode::SUCCESS;
37
}
38
39
40
StatusCode
CpuCruncherAlg::execute
()
41
{
42
ATH_MSG_DEBUG
(
"Executing "
<<
name
() <<
"..."
) ;
43
44
// Volatile to avoid optimization
45
volatile
double
test_result = 0.0;
46
47
// Sample randomly - use w/ care
48
double
ms_interval =
m_distribution
(
m_random
);
49
50
ATH_MSG_DEBUG
(
"Will burn CPU for "
<< ms_interval <<
" milliseconds ..."
);
51
52
// Define the interval, do some math until the interval is exhausted
53
std::chrono::duration<float, std::milli> chrono_interval(ms_interval);
54
55
auto
start
=
std::chrono::system_clock::now
();
56
57
while
(
std::chrono::system_clock::now
() -
start
< chrono_interval)
58
test_result +=
burn
(5000);
59
60
ATH_MSG_DEBUG
(
"Test result sum is "
<< test_result );
61
62
return
StatusCode::SUCCESS;
63
}
64
65
double
CpuCruncherAlg::burn
(
unsigned
long
nIterations = 10000000lu) {
66
67
// Volatile to avoid optimization
68
volatile
double
sum
= 0.0;
69
70
double
val
;
71
72
for
(
auto
idx
= 0lu;
idx
< nIterations; ++
idx
) {
73
val
= (
double
) (
idx
+ 1) / nIterations * 0.7854;
74
sum
+=
std::tan
(
std::log
(
val
));
75
}
76
77
return
sum
;
78
}
PerfMonTest::CpuCruncherAlg::execute
virtual StatusCode execute() override
Definition:
PerfMonTestCpuCruncherAlg.cxx:40
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition:
AthMsgStreamMacros.h:31
mergePhysValFiles.start
start
Definition:
DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:13
PerfMonTest::CpuCruncherAlg::burn
double burn(unsigned long nIterations)
Definition:
PerfMonTestCpuCruncherAlg.cxx:65
python.handimod.now
now
Definition:
handimod.py:674
convertTimingResiduals.sum
sum
Definition:
convertTimingResiduals.py:55
PerfMonTest::CpuCruncherAlg::m_rmsCpuTime
Gaudi::Property< float > m_rmsCpuTime
Property to setup the RMS (in ms) of CPU time to consume.
Definition:
PerfMonTestCpuCruncherAlg.h:49
PerfMonTest::CpuCruncherAlg::m_distribution
std::normal_distribution< double > m_distribution
Definition:
PerfMonTestCpuCruncherAlg.h:53
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition:
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition:
AthMsgStreamMacros.h:29
PerfMonTest::CpuCruncherAlg::m_meanCpuTime
Gaudi::Property< float > m_meanCpuTime
Property to setup the mean (in ms) of CPU time to consume.
Definition:
PerfMonTestCpuCruncherAlg.h:46
PerfMonTestCpuCruncherAlg.h
PerfMonTest
PerfMonTestPolyVectorAlg.h Example for the memory optimization tutorial.
Definition:
Control/PerformanceMonitoring/PerfMonTests/src/Hit.h:7
drawFromPickle.tan
tan
Definition:
drawFromPickle.py:36
xAOD::double
double
Definition:
CompositeParticle_v1.cxx:159
name
std::string name
Definition:
Control/AthContainers/Root/debug.cxx:240
PerfMonTest::CpuCruncherAlg::initialize
virtual StatusCode initialize() override
Definition:
PerfMonTestCpuCruncherAlg.cxx:24
Pythia8_RapidityOrderMPI.val
val
Definition:
Pythia8_RapidityOrderMPI.py:14
python.CaloCondTools.log
log
Definition:
CaloCondTools.py:20
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition:
LArNewCalib_DelayDump_OFC_Cali.py:69
PerfMonTest::CpuCruncherAlg::m_random
std::default_random_engine m_random
Random number setup.
Definition:
PerfMonTestCpuCruncherAlg.h:52
Generated on Mon Sep 29 2025 21:16:28 for ATLAS Offline Software by
1.8.18