Skip to content

Commit

Permalink
display time spent for the check. => v1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
mbruel committed Oct 17, 2020
1 parent 7f534b7 commit ae3ef0e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
28 changes: 20 additions & 8 deletions src/NzbCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <QCoreApplication>
#include <QCommandLineParser>
#include <QRegularExpression>
#include <QTime>

const QRegularExpression NzbCheck::sNntpArticleYencSubjectRegExp = QRegularExpression(sNntpArticleYencSubjectStrRegExp);

Expand Down Expand Up @@ -80,7 +81,16 @@ void NzbCheck::onDisconnected(NntpCon *con)
}

if (!_quietMode)
_cout << tr("Nb Missing Article(s): %1/%2").arg(_nbMissingArticles).arg(_nbTotalArticles) << "\n" << MB_FLUSH;
{
qint64 duration = _timeStart.elapsed();
_cout << tr("Nb Missing Article(s): %1/%2 (check done in %3 (%4 sec) using %5 connections on %6 server(s))").arg(
_nbMissingArticles).arg(
_nbTotalArticles).arg(
QTime::fromMSecsSinceStartOfDay(static_cast<int>(duration)).toString("hh:mm:ss.zzz")).arg(
std::round(1.*duration/1000)).arg(
_nbCons).arg(
_nntpServers.size()) << "\n" << MB_FLUSH;
}
qApp->quit();
}
}
Expand Down Expand Up @@ -192,11 +202,13 @@ int NzbCheck::parseNzb()

void NzbCheck::checkPost()
{
int nbCons = 0;
_timeStart.start();

_nbCons = 0;
for (NntpServerParams *srvParam : _nntpServers)
nbCons += srvParam->nbCons;
_nbCons += srvParam->nbCons;

nbCons = std::min(_nbTotalArticles, nbCons);
_nbCons = std::min(_nbTotalArticles, _nbCons);

int nb = 0;
for (NntpServerParams *srvParam : _nntpServers)
Expand All @@ -209,15 +221,15 @@ void NzbCheck::checkPost()

_connections.insert(con);

if (++nb == nbCons)
if (++nb == _nbCons)
break;
}
if (nb == nbCons)
if (nb == _nbCons)
break;
}

// if (debugMode())
_cout << tr("Using %1 Connections").arg(nbCons) << "\n" << MB_FLUSH;
if (debugMode())
_cout << tr("Using %1 Connections").arg(_nbCons) << "\n" << MB_FLUSH;

if (_dispProgressBar)
{
Expand Down
6 changes: 5 additions & 1 deletion src/NzbCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <QSet>
#include <QTimer>
#include <QCommandLineOption>
#include <QElapsedTimer>
class NntpServerParams;
class NntpCon;

Expand All @@ -43,7 +44,7 @@ class NzbCheck : public QObject

private:
static constexpr const char *sAppName = "nzbCheck";
static constexpr const char *sVersion = "1.2";
static constexpr const char *sVersion = "1.3";
static constexpr const char *sNntpServerStrRegExp = "^(([^:]+):([^@]+)@@@)?([\\w\\.\\-_]+):(\\d+):(\\d+):(no)?ssl$";
static constexpr const char *sNntpArticleYencSubjectStrRegExp = "^\\[\\d+/\\d+\\]\\s+.+\\(\\d+/(\\d+)\\)$";

Expand Down Expand Up @@ -78,6 +79,9 @@ class NzbCheck : public QObject

bool _quietMode;

QElapsedTimer _timeStart;
int _nbCons;

static const int sDefaultRefreshRate = 200; //!< how often shall we refresh the progressbar bar?
static const int sprogressbarBarWidth = 50;
static const QRegularExpression sNntpArticleYencSubjectRegExp;
Expand Down

0 comments on commit ae3ef0e

Please sign in to comment.