Base: Remove StopWatch
StopWatch is now used on single place only, remove it in favour of TimeElapsed
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -145,29 +145,6 @@ inline T fmod(T numerator, T denominator)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class BaseExport StopWatch
|
||||
{
|
||||
public:
|
||||
StopWatch();
|
||||
~StopWatch();
|
||||
|
||||
void start();
|
||||
int restart();
|
||||
int elapsed();
|
||||
std::string toString(int ms) const;
|
||||
|
||||
StopWatch(const StopWatch&) = delete;
|
||||
StopWatch(StopWatch&&) = delete;
|
||||
StopWatch& operator=(const StopWatch&) = delete;
|
||||
StopWatch& operator=(StopWatch&&) = delete;
|
||||
|
||||
private:
|
||||
struct Private;
|
||||
Private* d;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// NOLINTBEGIN
|
||||
template<typename Flag = bool>
|
||||
struct FlagToggler
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <Base/Console.h>
|
||||
#include <Base/FileInfo.h>
|
||||
#include <Base/Stream.h>
|
||||
#include <Base/TimeInfo.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Base/Writer.h>
|
||||
|
||||
@@ -171,9 +172,8 @@ void AutoSaver::saveDocument(const std::string& name, AutoSaveProperty& saver)
|
||||
getMainWindow()->showMessage(tr("Please wait until the AutoRecovery file has been saved..."), 5000);
|
||||
//qApp->processEvents();
|
||||
|
||||
Base::TimeElapsed startTime;
|
||||
// open extra scope to close ZipWriter properly
|
||||
Base::StopWatch watch;
|
||||
watch.start();
|
||||
{
|
||||
if (!this->compressed) {
|
||||
RecoveryWriter writer(saver);
|
||||
@@ -220,8 +220,7 @@ void AutoSaver::saveDocument(const std::string& name, AutoSaveProperty& saver)
|
||||
}
|
||||
}
|
||||
|
||||
std::string str = watch.toString(watch.elapsed());
|
||||
Base::Console().Log("Save AutoRecovery file: %s\n", str.c_str());
|
||||
Base::Console().Log("Save AutoRecovery file in %fs\n", Base::TimeElapsed::diffTimeF(startTime,Base::TimeElapsed()));
|
||||
hGrp->SetBool("SaveThumbnail",save);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user