ATLAS Offline Software
Loading...
Searching...
No Matches
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
14using 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}
#define ATH_MSG_DEBUG(x)
An STL vector of pointers that by default owns its pointed-to elements.
DataVector< IHit > HitPtrContainer
Derived DataVector<T>.
Definition DataVector.h:795
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
size_type capacity() const noexcept
Returns the total number of elements that the collection can hold before needing to allocate more mem...
Gaudi::Property< int > m_vectorSize
Property to setup the size of the Hit container.
Gaudi::Property< bool > m_mapIt
Property to introduce some fragmentation.
Gaudi::Property< int > m_2bReserved
Property to setup the amount of elements to reserve.
virtual StatusCode execute() override
Gaudi::Property< int > m_mixture
Property to set DHIT/FHIT ratio.
PerfMonTestPolyVectorAlg.h Example for the memory optimization tutorial.