MeVisLab Toolbox Reference
mlProcessingTimeLine.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2013, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef ML_PROCESSING_TIME_LINE_H
14 #define ML_PROCESSING_TIME_LINE_H
15 
17 
18 // ML-includes
19 #include "mlInitSystemML.h"
20 
21 #include "mlTimeCounter.h"
22 
23 #include <string>
24 #include <vector>
25 
26 ML_START_NAMESPACE
27 
30 {
31 public:
34 
36  void copyFrom(ProcessingTimeLine& timeline);
37 
39  class TimeLine
40  {
41  public:
42  TimeLine(ProcessingTimeLine* owner, const std::string& name) {
43  _name = name;
44  _owner = owner;
45  }
46 
48  struct Entry {
49  std::string info;
53  };
54 
56  int startEntry(const std::string& info, int processingScope = 0);
58  void stopEntry(int entryIndex);
59 
60  void load(std::ifstream& stream);
61 
62  void save(std::ofstream& stream);
63 
64  void copyFrom(TimeLine& timeline);
65 
67  double getMinimumTime();
68 
70  double getMaximumTime();
71 
72  void clear();
73 
74  const std::vector<Entry>& getEntries() const { return _entries; }
75 
76  const std::string& name() const { return _name; }
77 
78  private:
79  ProcessingTimeLine* _owner;
80  std::string _name;
81  std::vector<Entry> _entries;
82  };
83 
85  TimeLine* addTimeLine(const std::string& name);
86 
88  void removeTimeLine(TimeLine* timeLine);
89 
91  int getNumTimeLines() const { return static_cast<int>(_timeLines.size()); }
92 
94  TimeLine* getTimeLine(int i) const { return _timeLines[i]; }
95 
97  void resetRunningTime() { _timer.reset(); }
98 
101 
103  double getRunningTime();
104 
106  double getMaximumTime();
108  double getMinimumTime();
109 
111  void save(const std::string& fileName);
112 
114  void load(const std::string& fileName);
115 
117  void clear();
118 
119 private:
120  std::vector<TimeLine*> _timeLines;
121 
122  TimeCounter _timer;
123 
124  bool _firstEntry;
125 };
126 
127 ML_END_NAMESPACE
128 
129 #endif
130 
Timeline for a single thread.
double getMinimumTime()
Searches and returns the earliest time point measured.
int startEntry(const std::string &info, int processingScope=0)
Starts an entry and returns its index.
void copyFrom(TimeLine &timeline)
void stopEntry(int entryIndex)
Stops the entry at the given index.
const std::string & name() const
const std::vector< Entry > & getEntries() const
double getMaximumTime()
Searches and returns the latest time point measured.
TimeLine(ProcessingTimeLine *owner, const std::string &name)
void load(std::ifstream &stream)
void save(std::ofstream &stream)
Stores a processing timeline for multiple threads.
double getMinimumTime()
Searches and returns the earliest time point measured over all timelines.
void resetRunningTime()
Resets the running time, which affects getRunningTime().
TimeLine * addTimeLine(const std::string &name)
Adds a timeline with the given name. The ownership stays with ProcessingTimeLine.
void load(const std::string &fileName)
Reads timeline from disk.
void removeTimeLine(TimeLine *timeLine)
Removes the given timeline and deletes it.
double getRunningTime()
Returns the current running time in seconds.
double getMaximumTime()
Searches and returns the latest time point measured over all timelines.
TimeLine * getTimeLine(int i) const
Returns the timeline with given index i.
void clear()
Clears/removes the timelines.
void resetTimeLines()
Resets the timelines without deleting them.
void save(const std::string &fileName)
Saves timeline to disk.
int getNumTimeLines() const
Returns the number of timelines.
void copyFrom(ProcessingTimeLine &timeline)
Copies data from given timeline.
Class to measure precise time intervals.
Definition: mlTimeCounter.h:26
#define MLEXPORT
To export symbols from a DLL/shared object, we need to mark them with the MLEXPORT symbol.
double MLdouble
Definition: mlTypeDefs.h:217