CustusX  22.04-rc5
An IGT application
cxCyclicActionLogger.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 #ifndef CXCYCLICACTIONLOGGER_H_
12 #define CXCYCLICACTIONLOGGER_H_
13 
14 #include "cxResourceExport.h"
15 
16 #include "boost/shared_ptr.hpp"
17 #include <QTime>
18 #include <vector>
19 
20 namespace cx
21 {
22 
36 class cxResource_EXPORT CyclicActionLogger
37 {
38 public:
40  explicit CyclicActionLogger(QString name);
41  void reset(int interval = 1000);
42 
43  void begin();
44  void time(QString id);
45 
46  double getFPS();
47  bool intervalPassed() const;
48  QString dumpStatistics();
49  QString dumpStatisticsSmall();
50 
51  int getTime(QString id);
52  int getTotalLoggedTime();
53 
54 private:
55  QString mName;
56  struct Entry
57  {
58  QString id;
59  std::vector<double> time;
60  };
61  std::vector<Entry> mTiming;
62  QTime mRenderClock;
63  int mInterval;
64  QTime mIntervalClock;
65 
66  double getMeanTime(std::vector<double> &time);
67  double getMaxTime(std::vector<double> &time);
68  std::vector<Entry>::iterator getTimingVectorIterator(QString id);
69 };
70 
75 } // namespace cx
76 
77 #endif /* CXCYCLICACTIONLOGGER_H_ */
Scalar * begin()
Namespace for all CustusX production code.