Base: Remove StopWatch

StopWatch is now used on single place only, remove it in favour of TimeElapsed
This commit is contained in:
Ladislav Michl
2024-01-21 19:17:04 +01:00
parent e4d304f934
commit 1677e3d105
3 changed files with 3 additions and 87 deletions

View File

@@ -27,7 +27,6 @@
#include <locale>
#include <iostream>
#include <QDateTime>
#include <QElapsedTimer>
#endif
#include "PyExport.h"
@@ -373,62 +372,3 @@ std::string Base::Tools::currentDateTimeString()
.toString(Qt::ISODate)
.toStdString();
}
// ----------------------------------------------------------------------------
using namespace Base;
struct StopWatch::Private
{
QElapsedTimer t;
};
StopWatch::StopWatch()
: d(new Private)
{}
StopWatch::~StopWatch()
{
delete d;
}
void StopWatch::start()
{
d->t.start();
}
int StopWatch::restart()
{
return d->t.restart();
}
int StopWatch::elapsed()
{
return d->t.elapsed();
}
std::string StopWatch::toString(int ms) const
{
int total = ms;
int msec = total % 1000;
total = total / 1000;
int secs = total % 60;
total = total / 60;
int mins = total % 60;
int hour = total / 60;
std::stringstream str;
str << "Needed time: ";
if (hour > 0) {
str << hour << "h " << mins << "m " << secs << "s";
}
else if (mins > 0) {
str << mins << "m " << secs << "s";
}
else if (secs > 0) {
str << secs << "s";
}
else {
str << msec << "ms";
}
return str.str();
}