mirror of
https://github.com/NixOS/nix.git
synced 2024-11-25 00:02:25 +00:00
Log download durations
This commit is contained in:
parent
b13ba7490c
commit
caf4e98f0c
@ -71,7 +71,10 @@ struct curlFileTransfer : public FileTransfer
|
|||||||
|
|
||||||
curl_off_t writtenToSink = 0;
|
curl_off_t writtenToSink = 0;
|
||||||
|
|
||||||
|
std::chrono::steady_clock::time_point startTime = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
inline static const std::set<long> successfulStatuses {200, 201, 204, 206, 304, 0 /* other protocol */};
|
inline static const std::set<long> successfulStatuses {200, 201, 204, 206, 304, 0 /* other protocol */};
|
||||||
|
|
||||||
/* Get the HTTP status code, or 0 for other protocols. */
|
/* Get the HTTP status code, or 0 for other protocols. */
|
||||||
long getHTTPStatus()
|
long getHTTPStatus()
|
||||||
{
|
{
|
||||||
@ -373,10 +376,14 @@ struct curlFileTransfer : public FileTransfer
|
|||||||
|
|
||||||
void finish(CURLcode code)
|
void finish(CURLcode code)
|
||||||
{
|
{
|
||||||
|
auto finishTime = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
auto httpStatus = getHTTPStatus();
|
auto httpStatus = getHTTPStatus();
|
||||||
|
|
||||||
debug("finished %s of '%s'; curl status = %d, HTTP status = %d, body = %d bytes",
|
debug("finished %s of '%s'; curl status = %d, HTTP status = %d, body = %d bytes, duration = %.2f s",
|
||||||
request.verb(), request.uri, code, httpStatus, result.bodySize);
|
request.verb(), request.uri, code, httpStatus, result.bodySize,
|
||||||
|
std::chrono::duration_cast<std::chrono::milliseconds>(finishTime - startTime).count() / 1000.0f
|
||||||
|
);
|
||||||
|
|
||||||
appendCurrentUrl();
|
appendCurrentUrl();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user