From e1500aeef8172d79f91f884549374b0748451486 Mon Sep 17 00:00:00 2001 From: Hamatoma Date: Sat, 13 Feb 2016 12:10:06 +0100 Subject: [PATCH] rebackgui: Calculation of runtime --- appl/rebackgui/BackupEngine.cpp | 52 ++++++++++++++++----------------- appl/rebackgui/mainwindow.cpp | 2 +- base/ReQStringUtils.cpp | 2 +- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/appl/rebackgui/BackupEngine.cpp b/appl/rebackgui/BackupEngine.cpp index 8ee51a9..0a6b39a 100644 --- a/appl/rebackgui/BackupEngine.cpp +++ b/appl/rebackgui/BackupEngine.cpp @@ -206,8 +206,8 @@ void BackupTask::run() node = info.mid(pos + 1); copyFile(index, relPath, node); if (m_verboseLevel > VerboseQuiet){ - qint64 duration = QDateTime::currentMSecsSinceEpoch() - start.currentMSecsSinceEpoch(); - double factor = double(m_hotBytes) / max(1LL, m_processedBytes); + qint64 duration = QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch(); + double factor = double(m_processedBytes) / max(1LL, m_hotBytes); m_mainWindow->externalAppend(ReGuiQueueItem::StatusLine, NULL, tr("%1 of %2 (%3 of %4) %5 MB/sec runtime: %6") .arg(m_processedFiles).arg(m_hotFiles) @@ -220,7 +220,7 @@ void BackupTask::run() } m_mainWindow->externalTaskFinished(tr("backup complete after %1. Errors: %2") .arg(ReQStringUtils::readableDuration( - QDateTime::currentMSecsSinceEpoch() - start.currentMSecsSinceEpoch())) + QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch())) .arg(m_mainWindow->errors())); } @@ -397,18 +397,18 @@ void ChecksumOfTargetTask::run() error(QObject::tr("checksum differs: ") + relPath + node + " [" + sourceChecksum + "/" + checksum + "]"); } - qint64 processedBytes, hotBytes; - int hotFiles, processedFiles; - m_mutex.lock(); - hotFiles = m_hotFiles; - hotBytes = m_hotBytes; - processedBytes = m_processedBytes; - processedFiles = m_processedFiles; - m_mutex.unlock(); if (m_verboseLevel > VerboseQuiet){ - now = QDateTime::currentMSecsSinceEpoch(); - qint64 duration = (now - start.currentMSecsSinceEpoch()); - double factor = double(m_hotBytes) * 2 / max(1LL, m_processedBytes); + qint64 processedBytes, hotBytes; + int hotFiles, processedFiles; + m_mutex.lock(); + hotFiles = m_hotFiles; + hotBytes = m_hotBytes; + processedBytes = m_processedBytes; + processedFiles = m_processedFiles; + m_mutex.unlock(); + now = QDateTime::currentMSecsSinceEpoch(); + qint64 duration = (now - start.toMSecsSinceEpoch()); + double factor = m_processedBytes / double(max(1LL, m_hotBytes * 2)); m_mainWindow->externalAppend(ReGuiQueueItem::StatusLine, NULL, tr("%1 of %2 (%3 of %4) %5 MB/sec runtime: %6") .arg(processedFiles).arg(hotFiles * 2) @@ -422,7 +422,7 @@ void ChecksumOfTargetTask::run() } now = QDateTime::currentMSecsSinceEpoch(); m_mainWindow->externalTaskFinished(tr("Building target checksums complete after %1. Processed: %2 Errors: %3") - .arg(ReQStringUtils::readableDuration(now - start.currentMSecsSinceEpoch())) + .arg(ReQStringUtils::readableDuration(now - start.toMSecsSinceEpoch())) .arg(count) .arg(m_mainWindow->errors())); } @@ -526,8 +526,8 @@ void CleanTask::run() break; } if (m_verboseLevel > VerboseQuiet){ - double factor = double(m_hotFiles) / max(1, m_processedFiles); - qint64 duration = QDateTime::currentMSecsSinceEpoch() - start.currentMSecsSinceEpoch(); + double factor = double(m_processedFiles) / max(1, m_hotFiles); + qint64 duration = QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch(); m_mainWindow->externalAppend(ReGuiQueueItem::StatusLine, NULL, tr("%1 of %2 (%3 of %4) %5 MB/sec runtime: %6") .arg(m_processedFiles) @@ -542,7 +542,7 @@ void CleanTask::run() } m_mainWindow->externalTaskFinished(tr("backup complete after %1. Errors: %2") .arg(ReQStringUtils::readableDuration( - QDateTime::currentMSecsSinceEpoch() - start.currentMSecsSinceEpoch())) + QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch())) .arg(m_mainWindow->errors())); } @@ -639,29 +639,29 @@ void SearchTask::searchOneDirectory(const QString& source, m_mutex.unlock(); } else { qint64 diff = 0; - bool doCopy = false; + bool doTransfer = false; if (! m_compareWithTarget) - doCopy = true; + doTransfer = true; else if (target.isEmpty()) - doCopy = true; + doTransfer = true; else { QFileInfo trg(target + it.fileName()); if (! trg.exists()) - doCopy = true; + doTransfer = true; else { const QFileInfo src = it.fileInfo(); if (trg.size() != src.size()) - doCopy = true; + doTransfer = true; else if ((diff = src.lastModified().toMSecsSinceEpoch() - trg.lastModified().toMSecsSinceEpoch()) > 2000) - doCopy = true; + doTransfer = true; } } - if (doCopy){ + if (doTransfer){ info = prefix + it.fileName(); } m_mutex.lock(); - if (doCopy){ + if (doTransfer){ m_files.append(info); m_hotFiles++; m_hotBytes += it.fileInfo().size(); diff --git a/appl/rebackgui/mainwindow.cpp b/appl/rebackgui/mainwindow.cpp index c6bb036..860aa06 100644 --- a/appl/rebackgui/mainwindow.cpp +++ b/appl/rebackgui/mainwindow.cpp @@ -13,7 +13,7 @@ #include "aboutdialog.hpp" #include -const QString VERSION("2016.01.31"); +const QString VERSION("2016.02.13"); /** * Constructor. diff --git a/base/ReQStringUtils.cpp b/base/ReQStringUtils.cpp index 48057d5..8271905 100644 --- a/base/ReQStringUtils.cpp +++ b/base/ReQStringUtils.cpp @@ -546,7 +546,7 @@ QString ReQStringUtils::readableDuration(qint64 durationMilliSec){ */ QString ReQStringUtils::runtimeEstimation(const QDateTime& start, double factor){ - qint64 duration = QDateTime::currentMSecsSinceEpoch() - start.currentMSecsSinceEpoch(); + qint64 duration = QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch(); if (factor < 1) factor = 1; else if (factor <= 0.001) -- 2.39.5