mirror of https://github.com/aria2/aria2
Use A2_DELTA_MILLIS for timing critical code.
parent
a4ddec44d1
commit
891c9e60ac
|
@ -242,7 +242,7 @@ ConsoleStatCalc::ConsoleStatCalc(time_t summaryInterval, bool humanReadable):
|
|||
void
|
||||
ConsoleStatCalc::calculateStat(const DownloadEngine* e)
|
||||
{
|
||||
if(cp_.differenceInMillis(global::wallclock) < 900) {
|
||||
if(cp_.differenceInMillis(global::wallclock)+A2_DELTA_MILLIS < 1000) {
|
||||
return;
|
||||
}
|
||||
cp_ = global::wallclock;
|
||||
|
@ -271,7 +271,8 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
|
|||
std::ostringstream o;
|
||||
if(e->getRequestGroupMan()->countRequestGroup() > 0) {
|
||||
if((summaryInterval_ > 0) &&
|
||||
lastSummaryNotified_.difference(global::wallclock) >= summaryInterval_) {
|
||||
lastSummaryNotified_.differenceInMillis(global::wallclock)+
|
||||
A2_DELTA_MILLIS >= summaryInterval_*1000) {
|
||||
lastSummaryNotified_ = global::wallclock;
|
||||
printProgressSummary(e->getRequestGroupMan()->getRequestGroups(), cols, e,
|
||||
sizeFormatter);
|
||||
|
|
|
@ -246,7 +246,8 @@ TransferStat calculateStatFor(const SharedHandle<Peer>& peer)
|
|||
TransferStat DefaultPeerStorage::calculateStat()
|
||||
{
|
||||
TransferStat stat;
|
||||
if(lastTransferStatMapUpdated_.differenceInMillis(global::wallclock) >= 250) {
|
||||
if(lastTransferStatMapUpdated_.differenceInMillis(global::wallclock)+
|
||||
A2_DELTA_MILLIS >= 250) {
|
||||
A2_LOG_DEBUG("Updating TransferStat of PeerStorage");
|
||||
lastTransferStatMapUpdated_ = global::wallclock;
|
||||
peerTransferStatMap_.clear();
|
||||
|
|
|
@ -141,13 +141,6 @@ void executeCommand(std::deque<Command*>& commands,
|
|||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
|
||||
// Rounding error in millis
|
||||
const int A2_DELTA = 10;
|
||||
|
||||
} // namespace
|
||||
|
||||
void DownloadEngine::run()
|
||||
{
|
||||
Timer cp;
|
||||
|
@ -155,7 +148,8 @@ void DownloadEngine::run()
|
|||
while(!commands_.empty() || !routineCommands_.empty()) {
|
||||
global::wallclock.reset();
|
||||
calculateStatistics();
|
||||
if(cp.differenceInMillis(global::wallclock) >= refreshInterval_-A2_DELTA) {
|
||||
if(cp.differenceInMillis(global::wallclock)+A2_DELTA_MILLIS >=
|
||||
refreshInterval_) {
|
||||
refreshInterval_ = DEFAULT_REFRESH_INTERVAL;
|
||||
cp = global::wallclock;
|
||||
executeCommand(commands_, Command::STATUS_ALL);
|
||||
|
|
|
@ -404,7 +404,8 @@ void SegmentMan::updateFastestPeerStat(const SharedHandle<PeerStat>& peerStat)
|
|||
unsigned int SegmentMan::calculateDownloadSpeed()
|
||||
{
|
||||
unsigned int speed = 0;
|
||||
if(lastPeerStatDlspdMapUpdated_.differenceInMillis(global::wallclock) >= 250){
|
||||
if(lastPeerStatDlspdMapUpdated_.differenceInMillis(global::wallclock)+
|
||||
A2_DELTA_MILLIS >= 250){
|
||||
lastPeerStatDlspdMapUpdated_ = global::wallclock;
|
||||
peerStatDlspdMap_.clear();
|
||||
for(std::vector<SharedHandle<PeerStat> >::const_iterator i =
|
||||
|
|
|
@ -75,4 +75,7 @@
|
|||
# endif // !__MINGW32__
|
||||
#endif // !HAVE_CLOCK_GETTIME
|
||||
|
||||
// Rounding error in millis
|
||||
#define A2_DELTA_MILLIS 10
|
||||
|
||||
#endif // D_A2TIME_H
|
||||
|
|
Loading…
Reference in New Issue