PODIO v00-16-03
An Event-Data-Model Toolkit for High Energy Physics Experiments
Loading...
Searching...
No Matches
podio::TimedReader< WrappedReader > Class Template Reference

#include <TimedReader.h>

+ Inheritance diagram for podio::TimedReader< WrappedReader >:

Public Member Functions

template<typename... Args>
 TimedReader (benchmark::BenchmarkRecorder &recorder, Args &&... args)
 
 ~TimedReader ()
 
CollectionBasereadCollection (const std::string &name) override
 
std::shared_ptr< CollectionIDTablegetCollectionIDTable () override
 Get CollectionIDTable of read-in data.
 
GenericParametersreadEventMetaData () override
 read event meta data from file
 
std::map< int, GenericParameters > * readCollectionMetaData () override
 
std::map< int, GenericParameters > * readRunMetaData () override
 
unsigned getEntries () const override
 get the number of events available from this reader
 
void endOfEvent () override
 Prepare the reader to read the next event.
 
bool isValid () const override
 Check if reader is valid.
 
void openFile (const std::string &filename) override
 
void closeFile () override
 
void readEvent () override
 
void goToEvent (unsigned ev) override
 
podio::version::Version currentFileVersion () const override
 Get the podio version with which the current file has been written.
 
- Public Member Functions inherited from podio::IReader
virtual ~IReader ()=default
 
virtual CollectionBasereadCollection (const std::string &name)=0
 
virtual std::shared_ptr< CollectionIDTablegetCollectionIDTable ()=0
 Get CollectionIDTable of read-in data.
 
virtual GenericParametersreadEventMetaData ()=0
 read event meta data from file
 
virtual std::map< int, GenericParameters > * readCollectionMetaData ()=0
 
virtual std::map< int, GenericParameters > * readRunMetaData ()=0
 
virtual unsigned getEntries () const =0
 get the number of events available from this reader
 
virtual void endOfEvent ()=0
 Prepare the reader to read the next event.
 
virtual bool isValid () const =0
 Check if reader is valid.
 
virtual void openFile (const std::string &filename)=0
 
virtual void closeFile ()=0
 
virtual void readEvent ()=0
 
virtual void goToEvent (unsigned iEvent)=0
 
virtual podio::version::Version currentFileVersion () const =0
 Get the podio version with which the current file has been written.
 

Detailed Description

template<class WrappedReader>
class podio::TimedReader< WrappedReader >

Definition at line 15 of file TimedReader.h.

Constructor & Destructor Documentation

◆ TimedReader()

template<class WrappedReader >
template<typename... Args>
podio::TimedReader< WrappedReader >::TimedReader ( benchmark::BenchmarkRecorder recorder,
Args &&...  args 
)
inline

Definition at line 20 of file TimedReader.h.

20 :
21 m_start(ClockT::now()),
22 m_reader(WrappedReader(std::forward<Args>(args)...)),
23 m_end(ClockT::now()),
24 m_recorder(recorder),
25 m_perEventTree(m_recorder.addTree(
26 "event_times",
27 {"read_collections", "read_ev_md", "read_run_md", "read_coll_md", "end_of_event", "read_event"})) {
28 m_recorder.addTree("setup_times", {"constructor", "open_file", "close_file", "read_collection_ids", "get_entries"});
29 m_recorder.recordTime("setup_times", "constructor", m_end - m_start);
30 }
BenchmarkRecorderTree & addTree(const std::string &name, const std::vector< std::string > &steps)
void recordTime(const std::string &treeName, const std::string &stepName, const ClockT::duration time)

◆ ~TimedReader()

template<class WrappedReader >
podio::TimedReader< WrappedReader >::~TimedReader ( )
inline

Definition at line 32 of file TimedReader.h.

32 {
33 // Timing deconstructors is not straight forward when wrapping a value.
34 // Since nothing is usually happening in them in any case, we simply don't
35 // do it. We still have to fill the setup_times tree here though.
36 m_recorder.Fill("setup_times");
37 }
void Fill(const std::string &treeName)

Member Function Documentation

◆ closeFile()

template<class WrappedReader >
void podio::TimedReader< WrappedReader >::closeFile ( )
inlineoverridevirtual

Implements podio::IReader.

Definition at line 90 of file TimedReader.h.

90 {
91 runVoidTimed(false, "close_file", &IReader::closeFile);
92 }
virtual void closeFile()=0

Referenced by main().

◆ currentFileVersion()

template<class WrappedReader >
podio::version::Version podio::TimedReader< WrappedReader >::currentFileVersion ( ) const
inlineoverridevirtual

Get the podio version with which the current file has been written.

Implements podio::IReader.

Definition at line 103 of file TimedReader.h.

103 {
104 // no need to time this as it is really just a very simple get
105 return m_reader.currentFileVersion();
106 }

◆ endOfEvent()

template<class WrappedReader >
void podio::TimedReader< WrappedReader >::endOfEvent ( )
inlineoverridevirtual

Prepare the reader to read the next event.

Implements podio::IReader.

Definition at line 73 of file TimedReader.h.

73 {
74 runVoidTimed(true, "end_of_event", &IReader::endOfEvent);
75
76 m_perEventTree.recordTime("read_collections", m_totalCollectionReadTime);
77 m_perEventTree.Fill();
78 m_totalCollectionReadTime = std::chrono::nanoseconds{0};
79 }
virtual void endOfEvent()=0
Prepare the reader to read the next event.
void recordTime(const std::string &stepName, const ClockT::duration time)

◆ getCollectionIDTable()

template<class WrappedReader >
std::shared_ptr< CollectionIDTable > podio::TimedReader< WrappedReader >::getCollectionIDTable ( )
inlineoverridevirtual

Get CollectionIDTable of read-in data.

Implements podio::IReader.

Definition at line 50 of file TimedReader.h.

50 {
51 return runTimed(false, "read_collection_ids", &IReader::getCollectionIDTable);
52 }
virtual std::shared_ptr< CollectionIDTable > getCollectionIDTable()=0
Get CollectionIDTable of read-in data.

◆ getEntries()

template<class WrappedReader >
unsigned podio::TimedReader< WrappedReader >::getEntries ( ) const
inlineoverridevirtual

get the number of events available from this reader

Implements podio::IReader.

Definition at line 68 of file TimedReader.h.

68 {
69 return runTimed(false, "get_entries", &IReader::getEntries);
70 }
virtual unsigned getEntries() const =0
get the number of events available from this reader

◆ goToEvent()

template<class WrappedReader >
void podio::TimedReader< WrappedReader >::goToEvent ( unsigned  ev)
inlineoverridevirtual

Implements podio::IReader.

Definition at line 98 of file TimedReader.h.

98 {
99 // TODO: Do we need to time this? Not really used at the moment
100 m_reader.goToEvent(ev);
101 }

◆ isValid()

template<class WrappedReader >
bool podio::TimedReader< WrappedReader >::isValid ( ) const
inlineoverridevirtual

Check if reader is valid.

Implements podio::IReader.

Definition at line 82 of file TimedReader.h.

82 {
83 return m_reader.isValid();
84 }

◆ openFile()

template<class WrappedReader >
void podio::TimedReader< WrappedReader >::openFile ( const std::string &  filename)
inlineoverridevirtual

Implements podio::IReader.

Definition at line 86 of file TimedReader.h.

86 {
87 runVoidTimed(false, "open_file", &IReader::openFile, filename);
88 }
virtual void openFile(const std::string &filename)=0

Referenced by main().

◆ readCollection()

template<class WrappedReader >
CollectionBase * podio::TimedReader< WrappedReader >::readCollection ( const std::string &  name)
inlineoverridevirtual

Read Collection of given name Does not set references yet.

Implements podio::IReader.

Definition at line 41 of file TimedReader.h.

41 {
42 const auto [result, duration] = benchmark::run_member_timed(m_reader, &IReader::readCollection, name);
43 // since we cannot in general know how many collections there will be read
44 // we simply sum up all the requests in an event and record that
45 m_totalCollectionReadTime += duration;
46 return result;
47 }
virtual CollectionBase * readCollection(const std::string &name)=0
std::pair< std::invoke_result_t< MemberFunc, Obj, Args... >, ClockT::duration > run_member_timed(Obj &obj, MemberFunc func, Args &&... args)
Definition: BenchmarkUtil.h:17

◆ readCollectionMetaData()

template<class WrappedReader >
std::map< int, GenericParameters > * podio::TimedReader< WrappedReader >::readCollectionMetaData ( )
inlineoverridevirtual

Implements podio::IReader.

Definition at line 59 of file TimedReader.h.

59 {
60 return runTimed(true, "read_coll_md", &IReader::readCollectionMetaData);
61 }
virtual std::map< int, GenericParameters > * readCollectionMetaData()=0

◆ readEvent()

template<class WrappedReader >
void podio::TimedReader< WrappedReader >::readEvent ( )
inlineoverridevirtual

Implements podio::IReader.

Definition at line 94 of file TimedReader.h.

94 {
95 runVoidTimed(true, "read_event", &IReader::readEvent);
96 }
virtual void readEvent()=0

◆ readEventMetaData()

template<class WrappedReader >
GenericParameters * podio::TimedReader< WrappedReader >::readEventMetaData ( )
inlineoverridevirtual

read event meta data from file

Implements podio::IReader.

Definition at line 55 of file TimedReader.h.

55 {
56 return runTimed(true, "read_ev_md", &IReader::readEventMetaData);
57 }
virtual GenericParameters * readEventMetaData()=0
read event meta data from file

◆ readRunMetaData()

template<class WrappedReader >
std::map< int, GenericParameters > * podio::TimedReader< WrappedReader >::readRunMetaData ( )
inlineoverridevirtual

Implements podio::IReader.

Definition at line 63 of file TimedReader.h.

63 {
64 return runTimed(true, "read_run_md", &IReader::readRunMetaData);
65 }
virtual std::map< int, GenericParameters > * readRunMetaData()=0

The documentation for this class was generated from the following file: