diff options
-rw-r--r-- | apt-pkg/contrib/progress.cc | 2 | ||||
-rw-r--r-- | ftparchive/apt-ftparchive.cc | 36 |
2 files changed, 14 insertions, 24 deletions
diff --git a/apt-pkg/contrib/progress.cc b/apt-pkg/contrib/progress.cc index 806bd47f8..971198270 100644 --- a/apt-pkg/contrib/progress.cc +++ b/apt-pkg/contrib/progress.cc @@ -123,7 +123,7 @@ bool OpProgress::CheckChange(float Interval) std::chrono::duration<decltype(Interval)> Delta = std::chrono::seconds(NowTime.tv_sec - LastTime.tv_sec) + - std::chrono::microseconds(NowTime.tv_sec - LastTime.tv_usec); + std::chrono::microseconds(NowTime.tv_usec - LastTime.tv_usec); if (Delta.count() < Interval) return false; diff --git a/ftparchive/apt-ftparchive.cc b/ftparchive/apt-ftparchive.cc index 077701cc0..87ce9153c 100644 --- a/ftparchive/apt-ftparchive.cc +++ b/ftparchive/apt-ftparchive.cc @@ -56,6 +56,15 @@ static struct timeval GetTimevalFromSteadyClock() /*{{{*/ return { Time_sec.count(), Time_usec.count() }; } /*}}}*/ +static auto GetTimeDeltaSince(struct timeval StartTime) /*{{{*/ +{ + auto const NewTime = GetTimevalFromSteadyClock(); + std::chrono::duration<double> Delta = + std::chrono::seconds(NewTime.tv_sec - StartTime.tv_sec) + + std::chrono::microseconds(NewTime.tv_usec - StartTime.tv_usec); + return llround(Delta.count()); +} + /*}}}*/ // struct PackageMap - List of all package files in the config file /*{{{*/ // --------------------------------------------------------------------- @@ -241,16 +250,11 @@ bool PackageMap::GenPackages(Configuration &Setup,struct CacheDB::Stats &Stats) << SizeToStr(Size) << "B "; else c0out << ' '; - - struct timeval NewTime = GetTimevalFromSteadyClock(); - std::chrono::duration<double> Delta = - std::chrono::seconds(NewTime.tv_sec - StartTime.tv_sec) + - std::chrono::microseconds(NewTime.tv_sec - StartTime.tv_usec); c0out << Packages.Stats.Packages << " files " << /* SizeToStr(Packages.Stats.MD5Bytes) << "B/" << */ SizeToStr(Packages.Stats.Bytes) << "B " << - TimeToStr(llround(Delta.count())) << endl; + TimeToStr(GetTimeDeltaSince(StartTime)) << endl; if(_config->FindB("APT::FTPArchive::ShowCacheMisses", false) == true) c0out << " Misses in Cache: " << Packages.Stats.Misses<< endl; @@ -328,13 +332,8 @@ bool PackageMap::GenSources(Configuration &Setup,struct CacheDB::Stats &Stats) else c0out << ' '; - struct timeval NewTime = GetTimevalFromSteadyClock(); - std::chrono::duration<double> Delta = - std::chrono::seconds(NewTime.tv_sec - StartTime.tv_sec) + - std::chrono::microseconds(NewTime.tv_sec - StartTime.tv_usec); - c0out << Sources.Stats.Packages << " pkgs in " << - TimeToStr(llround(Delta.count())) << endl; + TimeToStr(GetTimeDeltaSince(StartTime)) << endl; if(_config->FindB("APT::FTPArchive::ShowCacheMisses", false) == true) c0out << " Misses in Cache: " << Sources.Stats.Misses << endl; @@ -444,17 +443,12 @@ bool PackageMap::GenContents(Configuration &Setup, else c0out << ' '; - struct timeval NewTime = GetTimevalFromSteadyClock(); - std::chrono::duration<double> Delta = - std::chrono::seconds(NewTime.tv_sec - StartTime.tv_sec) + - std::chrono::microseconds(NewTime.tv_sec - StartTime.tv_usec); - if(_config->FindB("APT::FTPArchive::ShowCacheMisses", false) == true) c0out << " Misses in Cache: " << Contents.Stats.Misses<< endl; c0out << Contents.Stats.Packages << " files " << SizeToStr(Contents.Stats.Bytes) << "B " << - TimeToStr(llround(Delta.count())) << endl; + TimeToStr(GetTimeDeltaSince(StartTime)) << endl; return true; } @@ -970,12 +964,8 @@ static bool Generate(CommandLine &CmdL) return false; } - struct timeval NewTime = GetTimevalFromSteadyClock(); - std::chrono::duration<double> Delta = - std::chrono::seconds(NewTime.tv_sec - StartTime.tv_sec) + - std::chrono::microseconds(NewTime.tv_sec - StartTime.tv_usec); c1out << "Done. " << SizeToStr(Stats.Bytes) << "B in " << Stats.Packages - << " archives. Took " << TimeToStr(llround(Delta.count())) << endl; + << " archives. Took " << TimeToStr(GetTimeDeltaSince(StartTime)) << endl; UnloadTree(TransList); return true; |