ATLAS Offline Software
Loading...
Searching...
No Matches
PerfMonTestPolyVectorAlgWithArenas.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
7#include "AthAllocators/DataPool.h" /* NEW */
8
9#include "Hit.h"
11/* #define DEBUG_ME 1 */
12
13using namespace PerfMonTest;
14
16
17
19{
20 DataPool<DHit> dhitPool;
21 DataPool<FHit> fhitPool;
22 ATH_MSG_DEBUG("Executing ");
23 HitPtrContainer vptr(SG::VIEW_ELEMENTS); //<<< NEW
24 vptr.reserve(m_2bReserved.value());
25 int vcap(vptr.capacity());
26 int vold;
27#ifdef DEBUG_ME
28 IHit* p1(0);
29 IHit* p2(0);
30#endif
31 IHit* p3(0);
32 std::cout << "initial capacity " << vcap << std::endl;
33 int size(m_vectorSize.value());
34 for(int i(0); i<size; ++i) {
35 vold=vcap;
36#ifdef DEBUG_ME
37 p1=p2;
38 p2=p3;
39#endif
40 p3=(i % m_mixture.value()) ?
41 (IHit*) new(fhitPool.nextElementPtr()) FHit(i, i, i):
42 (IHit*) new(dhitPool.nextElementPtr()) DHit(i, i, i); //<<< NEW
43 vptr.push_back(p3);
44 vcap=vptr.capacity();
45 if (m_mapIt.value()) m_mixMap[i]=p3;
46 if (vold != vcap) std::cout << "iteration " << i << " new capacity " << vcap <<std::endl;
47#ifdef DEBUG_ME
48 if (((int)p3-(int)p2) != ((int)p2-(int)p1)) std::cout << "iteration " << i << " new chunk @" << hex << p3 << " previous was @" << p2 << dec << std::endl;
49#ifdef REALLY_DEBUG_ME
50 std::cout << "iteration " << i << " P3 @" << hex << p3 << " p2 @" << p2 << " p1 @" << p1 << dec << ' ' << (int)p3-(int)p2 << ' ' <<(int)p2-(int)p1 <<std::endl;
51#endif
52#endif
53 }
54
55 return StatusCode::SUCCESS;
56}
#define ATH_MSG_DEBUG(x)
An STL vector of pointers that by default owns its pointed-to elements.
DataVector< IHit > HitPtrContainer
a typed memory pool that saves time spent allocation small object.
Definition DataPool.h:63
pointer nextElementPtr()
obtain the next available element in pool by pointer pool is resized if its limit has been reached On...
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_2bReserved
Property to setup the amount of elements to reserve.
Gaudi::Property< int > m_mixture
Property to set DHIT/FHIT ratio.
Gaudi::Property< bool > m_mapIt
Property to introduce some fragmentation.
Gaudi::Property< int > m_vectorSize
Property to setup the size of the Hit container.
PerfMonTestPolyVectorAlg.h Example for the memory optimization tutorial.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts