ATLAS Offline Software
PerfMonTestPolyVectorAlg.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 #include <map>
8 
9 #include "Hit.h"
11 
12 /* #define DEBUG_ME 1 */
13 
14 using namespace PerfMonTest;
15 
17 
18 
20 {
21  ATH_MSG_DEBUG("Executing ");
22  HitPtrContainer vptr;
23  vptr.reserve(m_2bReserved.value());
24  int vcap(vptr.capacity());
25  int vold;
26 #ifdef DEBUG_ME
27  IHit* p1(0);
28  IHit* p2(0);
29 #endif
30  IHit* p3(0);
31  std::cout << "initial capacity " << vcap << std::endl;
32  int size(m_vectorSize.value());
33  for(int i(0); i<size; ++i) {
34  vold=vcap;
35 #ifdef DEBUG_ME
36  p1=p2;
37  p2=p3;
38 #endif
39  p3=(i % m_mixture.value()) ?
40  (IHit*)new FHit(i, i, i):
41  (IHit*)new DHit(i, i, i);
42  vptr.push_back(p3);
43  vcap=vptr.capacity();
44  if (m_mapIt.value()) m_mixMap[i]=p3;
45  if (vold != vcap) std::cout << "iteration " << i << " new capacity " << vcap <<std::endl;
46 #ifdef DEBUG_ME
47  if (((int)p3-(int)p2) != ((int)p2-(int)p1)) cout << "iteration " << i << " new chunk @" << hex << p3 << " previous was @" << p2 << dec << endl;
48 #ifdef REALLY_DEBUG_ME
49  std::cout << "iteration " << i << " P3 @" << hex << p3 << " p2 @" << p2 << " p1 @" << p1 << dec << ' ' << (int)p3-(int)p2 << ' ' <<(int)p2-(int)p1 <<std::endl;
50 #endif
51 #endif
52  }
53 
54  return StatusCode::SUCCESS;
55 }
DataVector::reserve
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
HitPtrContainer
DataVector< IHit > HitPtrContainer
Definition: PerfMonTestPolyVectorAlg.cxx:16
PerfMonTest::PolyVectorAlg::execute
virtual StatusCode execute() override
Definition: PerfMonTestPolyVectorAlg.cxx:19
PerfMonTest::FHit
Definition: Control/PerformanceMonitoring/PerfMonTests/src/Hit.h:30
AthMsgStreamMacros.h
PerfMonTest::DHit
Definition: Control/PerformanceMonitoring/PerfMonTests/src/Hit.h:15
TRTCalib_cfilter.p1
p1
Definition: TRTCalib_cfilter.py:130
PerfMonTest::IHit
Definition: Control/PerformanceMonitoring/PerfMonTests/src/Hit.h:8
PerfMonTest::PolyVectorAlg::m_2bReserved
Gaudi::Property< int > m_2bReserved
Property to setup the amount of elements to reserve.
Definition: PerfMonTestPolyVectorAlg.h:29
PerfMonTest::PolyVectorAlg::m_mapIt
Gaudi::Property< bool > m_mapIt
Property to introduce some fragmentation.
Definition: PerfMonTestPolyVectorAlg.h:33
PerfMonTest::PolyVectorAlg::m_mixture
Gaudi::Property< int > m_mixture
Property to set DHIT/FHIT ratio.
Definition: PerfMonTestPolyVectorAlg.h:31
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
TRTCalib_cfilter.p2
p2
Definition: TRTCalib_cfilter.py:131
PerfMonTestPolyVectorAlg.h
lumiFormat.i
int i
Definition: lumiFormat.py:85
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
Hit.h
PerfMonTest
PerfMonTestPolyVectorAlg.h Example for the memory optimization tutorial.
Definition: Control/PerformanceMonitoring/PerfMonTests/src/Hit.h:7
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
DataVector::capacity
size_type capacity() const noexcept
Returns the total number of elements that the collection can hold before needing to allocate more mem...
PerfMonTest::PolyVectorAlg::m_mixMap
std::map< int, IHit * > m_mixMap
Definition: PerfMonTestPolyVectorAlg.h:34
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DataVector.h
An STL vector of pointers that by default owns its pointed-to elements.
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
PerfMonTest::PolyVectorAlg::m_vectorSize
Gaudi::Property< int > m_vectorSize
Property to setup the size of the Hit container.
Definition: PerfMonTestPolyVectorAlg.h:27
TRTCalib_cfilter.p3
p3
Definition: TRTCalib_cfilter.py:132