@ -23,6 +23,7 @@
# include <apt-private/private-output.h>
# include <algorithm>
# include <chrono>
# include <climits>
# include <functional>
# include <iostream>
@ -33,6 +34,7 @@
# include <sys/stat.h>
# include <sys/time.h>
# include <time.h>
# include <math.h>
# include "apt-ftparchive.h"
# include "cachedb.h"
@ -46,6 +48,15 @@
using namespace std ;
unsigned Quiet = 0 ;
static struct timeval GetTimevalFromSteadyClock ( ) /* { { { */
{
auto const Time = std : : chrono : : steady_clock : : now ( ) . time_since_epoch ( ) ;
auto const Time_sec = std : : chrono : : duration_cast < std : : chrono : : seconds > ( Time ) ;
auto const Time_usec = std : : chrono : : duration_cast < std : : chrono : : microseconds > ( Time - Time_sec ) ;
return { Time_sec . count ( ) , Time_usec . count ( ) } ;
}
/*}}}*/
// struct PackageMap - List of all package files in the config file /*{{{*/
// ---------------------------------------------------------------------
/* */
@ -173,9 +184,8 @@ bool PackageMap::GenPackages(Configuration &Setup,struct CacheDB::Stats &Stats)
string OverrideDir = Setup . FindDir ( " Dir::OverrideDir " ) ;
string CacheDir = Setup . FindDir ( " Dir::CacheDir " ) ;
struct timeval StartTime ;
gettimeofday ( & StartTime , 0 ) ;
struct timeval StartTime = GetTimevalFromSteadyClock ( ) ;
PkgDone = true ;
// Create a package writer object.
@ -232,15 +242,15 @@ bool PackageMap::GenPackages(Configuration &Setup,struct CacheDB::Stats &Stats)
else
c0out < < ' ' ;
struct timeval NewTime ;
gettimeofday ( & NewTime , 0 ) ;
double Delta = NewTime . tv_sec - StartTime . tv_sec +
( NewTime . tv_u sec - StartTime . tv_usec ) / 1000000.0 ;
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 ( ( long ) Delta ) < < endl ;
TimeToStr ( llround ( Delta . count ( ) ) ) < < endl ;
if ( _config - > FindB ( " APT::FTPArchive::ShowCacheMisses " , false ) = = true )
c0out < < " Misses in Cache: " < < Packages . Stats . Misses < < endl ;
@ -264,9 +274,7 @@ bool PackageMap::GenSources(Configuration &Setup,struct CacheDB::Stats &Stats)
string OverrideDir = Setup . FindDir ( " Dir::OverrideDir " ) ;
string CacheDir = Setup . FindDir ( " Dir::CacheDir " ) ;
struct timeval StartTime ;
gettimeofday ( & StartTime , 0 ) ;
struct timeval StartTime = GetTimevalFromSteadyClock ( ) ;
SrcDone = true ;
// Create a package writer object.
@ -320,13 +328,13 @@ bool PackageMap::GenSources(Configuration &Setup,struct CacheDB::Stats &Stats)
else
c0out < < ' ' ;
struct timeval NewTime ;
gettimeofday ( & NewTime , 0 ) ;
double Delta = NewTime . tv_sec - StartTime . tv_sec +
( NewTime . tv_u sec - StartTime . tv_usec ) / 1000000.0 ;
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 ( ( long ) Delta ) < < endl ;
TimeToStr ( llround ( Delta . count ( ) ) ) < < endl ;
if ( _config - > FindB ( " APT::FTPArchive::ShowCacheMisses " , false ) = = true )
c0out < < " Misses in Cache: " < < Sources . Stats . Misses < < endl ;
@ -356,10 +364,9 @@ bool PackageMap::GenContents(Configuration &Setup,
string ArchiveDir = Setup . FindDir ( " Dir::ArchiveDir " ) ;
string CacheDir = Setup . FindDir ( " Dir::CacheDir " ) ;
string OverrideDir = Setup . FindDir ( " Dir::OverrideDir " ) ;
struct timeval StartTime ;
gettimeofday ( & StartTime , 0 ) ;
struct timeval StartTime = GetTimevalFromSteadyClock ( ) ;
// Create a package writer object.
MultiCompress Comp ( flCombine ( ArchiveDir , this - > Contents ) ,
CntCompress , Permissions ) ;
@ -437,17 +444,17 @@ bool PackageMap::GenContents(Configuration &Setup,
else
c0out < < ' ' ;
struct timeval NewTime ;
gettimeofday ( & NewTime , 0 ) ;
double Delta = NewTime . tv_sec - StartTime . tv_sec +
( NewTime . tv_u sec - StartTime . tv_usec ) / 1000000.0 ;
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 ( ( long ) Delta ) < < endl ;
TimeToStr ( llround ( Delta . count ( ) ) ) < < endl ;
return true ;
}
@ -926,8 +933,7 @@ static bool Generate(CommandLine &CmdL)
if ( CmdL . FileSize ( ) < 2 )
return ShowHelp ( CmdL ) ;
struct timeval StartTime ;
gettimeofday ( & StartTime , 0 ) ;
struct timeval StartTime = GetTimevalFromSteadyClock ( ) ;
struct CacheDB : : Stats Stats ;
// Read the configuration file.
@ -964,12 +970,12 @@ static bool Generate(CommandLine &CmdL)
return false ;
}
struct timeval NewTime ;
gettimeofday ( & NewTime , 0 ) ;
double Delta = NewTime . tv_sec - StartTime . tv_sec +
( NewTime . tv_u sec - StartTime . tv_usec ) / 1000000.0 ;
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 ( ( long ) Delta ) < < endl ;
< < " archives. Took " < < TimeToStr ( llround ( Delta . count ( ) ) ) < < endl ;
UnloadTree ( TransList ) ;
return true ;