Fraxinus  2023.01.05-dev+develop.0da12
An IGT application
cxTimeKeeper.cpp
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 
12 
13 #include "cxTimeKeeper.h"
14 #include "cxLogger.h"
15 #include "cxReporter.h"
16 
17 namespace cx
18 {
19 
20 TimeKeeper::TimeKeeper() : mTime(QDateTime::currentDateTime()) {}
21 
23 {
24  reporter()->sendDebug(text + ": " + this->getElapsedSecondsAsString() + "s");
25 }
26 void TimeKeeper::printElapsedms(QString text) const
27 {
28  reporter()->sendDebug(QString(text + ": %1").arg(getElapsedms()));
29 }
30 
32 {
33  double secs = double(this->getElapsedms())/1000;
34  return QString("%1").arg(secs, 0, 'f', 2);
35 }
37 {
38  return mTime.msecsTo(QDateTime::currentDateTime());
39 }
40 
42 {
43  mTime = QDateTime::currentDateTime();
44 }
45 
46 } // namespace cx
ReporterPtr reporter()
Definition: cxReporter.cpp:36
void printElapsedms(QString text="Elapsed") const
int getElapsedms() const
QString getElapsedSecondsAsString() const
void printElapsedSeconds(QString text="Elapsed time")
Namespace for all CustusX production code.