ATLAS Offline Software
Loading...
Searching...
No Matches
PerfMonTestVectorAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5
7
8#include "Hit.h"
10#include <map>
11#include <vector>
12
13/* #define DEBUG_ME 1 */
14
15using namespace PerfMonTest;
16using namespace::std;
17
19
20
21StatusCode VectorAlg::execute(const EventContext& /*ctx*/)
22{
23 ATH_MSG_DEBUG("Executing ");
24 HitContainer vhit;
25 vhit.reserve(m_2bReserved.value());
26 int vcap(vhit.capacity());
27 int vold;
28#ifdef DEBUG_ME
29 IHit* p1(0);
30 IHit* p2(0);
31#endif
32 IHit* p3(0);
33 cout << "initial capacity " << vcap << endl;
34 int size(m_vectorSize.value());
35 for(int i(0); i<size; ++i) {
36 vold=vcap;
37#ifdef DEBUG_ME
38 p1=p2;
39 p2=p3;
40#endif
41 vhit.push_back(DHit(i,i,i));
42 vcap=vhit.capacity();
43 //I'm going to assume this is deliberate, as it is for a tutorial
44 //coverity[WRAPPER_ESCAPE]
45 p3=&vhit[i];
46 if (m_mapIt.value()) m_mixMap[i]=p3;
47 if (vold != vcap) cout << "iteration " << i << " new capacity " << vcap <<endl;
48#ifdef DEBUG_ME
49 if (((int)p3-(int)p2) != ((int)p2-(int)p1)) cout << "iteration " << i << " new chunk @" << hex << p3 << " previous was @" << p2 << dec << endl;
50#ifdef REALLY_DEBUG_ME
51 cout << "iteration " << i << " P3 @" << hex << p3 << " p2 @" << p2 << " p1 @" << p1 << dec << ' ' << (int)p3-(int)p2 << ' ' <<(int)p2-(int)p1 <<endl;
52#endif
53#endif
54 }
55
56 return StatusCode::SUCCESS;
57}
#define ATH_MSG_DEBUG(x)
vector< DHit > HitContainer
size_t size() const
Number of registered mappings.
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
Gaudi::Property< int > m_vectorSize
Property to setup the size of the Hit container.
std::map< int, IHit * > m_mixMap
Gaudi::Property< bool > m_mapIt
Property to introduce some fragmentation.
Gaudi::Property< int > m_2bReserved
Property to setup the amount of elements to reserve.
PerfMonTestPolyVectorAlg.h Example for the memory optimization tutorial.