ATLAS Offline Software
Loading...
Searching...
No Matches
PerfMonTestMallocAlg.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// PerfMonTestMallocAlg.cxx
6// Implementation file for class PerfMonTest::MallocAlg
7// Author: S.Binet<binet@cern.ch>
9
10
11// STL includes
12#include <vector>
13
14// FrameWork includes
15#include "Gaudi/Property.h"
16
17// CLHEP includes
18#include "CLHEP/Units/SystemOfUnits.h"
19#include "CLHEP/Random/RandGauss.h"
20
21// PerfMonTests includes
23
24using namespace PerfMonTest;
25
26
28{
29 ATH_MSG_DEBUG ( "Executing " << name() << "..." ) ;
30
32
33 //typedef int ElemType;
34 typedef float ElemType;
35
36 if ( m_currentEvtNbr >= m_evtNbr ) {
37 const std::size_t nmax = 1024*1024;
38
39 if (m_useStdVector) {
40 std::vector<ElemType> c1_array(nmax);
41 for ( std::size_t i = 0; i!=nmax; ++i ) {
42 c1_array[i] = i;
43 }
44
45 if ( m_currentEvtNbr >= 2*m_evtNbr ) {
46 std::vector<ElemType> c2_array(nmax);
47 for ( std::size_t i = 0; i!=nmax; ++i ) {
48 c2_array[i] = -1*static_cast<int>(i);
49 }
50 }
51
52 } else {
53 ElemType c1_array[nmax];
54 for ( std::size_t i = 0; i!=nmax; ++i ) {
55 c1_array[i] = i;
56 }
57 isUsed (&c1_array);
58
59 if ( m_currentEvtNbr >= 2*m_evtNbr ) {
60 ElemType c2_array[nmax];
61 for ( std::size_t i = 0; i!=nmax; ++i ) {
62 c2_array[i] = -1*static_cast<int>(i);
63 }
64 // dummy stuff to silence gcc-warning.
65 if (c2_array[0] > c1_array[0]) {
66 c2_array[0] = c1_array[0];
67 }
68 }
69 }
70 }
71
72 return StatusCode::SUCCESS;
73}
#define ATH_MSG_DEBUG(x)
const int nmax(200)
virtual void isUsed(const void *)
unsigned int m_currentEvtNbr
current event number
Gaudi::Property< bool > m_useStdVector
switch between using a C-array and a std::vector
virtual StatusCode execute() override
Gaudi::Property< unsigned int > m_evtNbr
event number at which to actually do stuff
PerfMonTestPolyVectorAlg.h Example for the memory optimization tutorial.