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 smallest time point that was 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 highest time point that was measured
TimeLine(ProcessingTimeLine *owner, const std::string &name)
void load(std::ifstream &stream)
void save(std::ofstream &stream)
Stores a processing time line for multiple threads.
double getMinimumTime()
searches and returns the smallest time point that was measured over all time lines
void resetRunningTime()
reset the running time (which affects getRunningTime())
TimeLine * addTimeLine(const std::string &name)
adds a time line with given name, ownership stays with ProcessingTimeLine
void load(const std::string &fileName)
read timeline from disk
void removeTimeLine(TimeLine *timeLine)
removes the given time line (and deletes it)
double getRunningTime()
get the current running time in seconds
double getMaximumTime()
searches and returns the highest time point that was measured over all time lines
TimeLine * getTimeLine(int i) const
get time line with given index
void clear()
clears/removes the timelines
void resetTimeLines()
reset the time lines (without deleting them)
void save(const std::string &fileName)
save timeline to disk
int getNumTimeLines() const
get the number of time lines
void copyFrom(ProcessingTimeLine &timeline)
copy 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:223