18 using namespace lcio ;
35 m_pTFile = std::make_shared<TFile>( fname.
c_str() ,
"RECREATE" ) ;
36 m_pTTree =
new TTree(
"LCIOBenchmark",
"LCIOBenchmark" ) ;
37 m_pTTree->SetDirectory( m_pTFile.get() ) ;
39 m_pTTree->Branch(
"ProcRSS", &m_procRSS,
"ProcRSS/Long_t" ) ;
41 m_pTTree->Branch(
"ReadTime", &m_readTime ) ;
42 m_pTTree->Branch(
"ReadRSS", &m_readResidentMemory,
"ReadRSS/Long_t" ) ;
44 m_pTTree->Branch(
"WriteTime", &m_writeTime ) ;
45 m_pTTree->Branch(
"WriteRSS", &m_writeRSS,
"WriteRSS/Long_t" ) ;
47 m_pTTree->Branch(
"Entry", &m_entry ) ;
50 gSystem->GetProcInfo(&procInfo);
51 m_residentMemoryReference = procInfo.fMemResident;
52 m_firstClock = m_lastClock =
clock();
54 m_lcWriter = LCFactory::getInstance()->createLCWriter();
55 m_lcioOutputFileName <<
"LCIO_benchmarking_" << gSystem->GetPid() <<
".slcio";
57 m_lcWriter->open( m_lcioOutputFileName.str(), LCIO::WRITE_NEW );
64 std::cout <<
"Closing and deleting LCIO file " << m_lcioOutputFileName.str() <<
std::endl;
67 std::remove( m_lcioOutputFileName.str().c_str() );
68 std::cout <<
"Total processing time was " << float(m_lastClock - m_firstClock) / CLOCKS_PER_SEC <<
" secs" <<
std::endl;
89 ProcInfo_t procInfo, procInfo2 ;
91 m_readTime = float( currentClock - m_lastClock ) / CLOCKS_PER_SEC ;
92 gSystem->GetProcInfo(&procInfo);
93 m_procRSS = procInfo.fMemResident;
94 m_readResidentMemory = ( procInfo.fMemResident - m_residentMemoryReference ) ;
97 m_lcWriter->writeEvent(event) ;
99 gSystem->GetProcInfo(&procInfo2) ;
100 m_writeTime = float( writeEnd - writeStart ) / CLOCKS_PER_SEC ;
101 m_writeRSS = ( procInfo2.fMemResident - procInfo.fMemResident ) ;
102 m_residentMemoryReference = procInfo2.fMemResident ;
103 m_lastClock =
clock();
126 TTree *m_pTTree {
nullptr} ;
132 Float_t m_readTime {0} ;
138 Long_t m_residentMemoryReference {0} ;
140 Long_t m_readResidentMemory {0} ;
144 Float_t m_writeTime {0} ;
146 Long_t m_writeRSS {0} ;
148 Long_t m_procRSS {0} ;
153 int main(
int argc,
char** argv ){
157 cout <<
" read/write LCIO file and output io benchmarks in a ROOT file" <<
endl <<
endl;
158 cout <<
" usage: lcio_io_benchmark <input-file> <output-file> [<nevents>]" <<
endl ;
166 nevents =
atoi( argv[3] );
169 auto lcReader = LCFactory::getInstance()->createLCReader() ;
173 lcReader->registerLCEventListener(benchmark);
174 lcReader->registerLCRunListener(benchmark);
void processEvent(EVENT::LCEvent *evt)
Extract and fill benchmark variables.
BenchmarkListener(const std::string &fname)
Constructor.
~BenchmarkListener()
Destructor.
void modifyRunHeader(EVENT::LCRunHeader *)
Call back for modifying an existing LCRunHeader.
BenchmarkListener class Simple event/run listener getting memory/proc statistics on callback...
Listener for the occurence of LCEvents when reading a stream.
int main(int argc, char **argv)
Simple program that opens existing LCIO files and appends the records needed for direct access - if t...
Listener for the occurence of LCRunHeader when reading a stream.
void write()
Write benchmarks to ROOT file.
void processRunHeader(EVENT::LCRunHeader *)
Call back for processing an LCRunHeader.
The main event interface.
void getVariables(EVENT::LCEvent *event)
Extract benchmark variables.
void modifyEvent(EVENT::LCEvent *)
Call back for updating an LCEvent.
Interface for writing data with LCIO.
EndOfDataException for signaling the end of a data stream.