{"thread":{"id":"46327","subject":"0 bytes/s vs. ∞ bytes/s","startedAt":"2017-07-08T04:01:22Z","lastAt":"2017-07-08T19:30:34Z","messageCount":3,"participants":["積丹尼 Dan Jacobson","René Scharfe"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"323984","messageId":"87lgo02qat.fsf@jidanni.org","threadId":"46327","inReplyTo":null,"subject":"0 bytes/s vs. ∞ bytes/s","fromName":"積丹尼 Dan Jacobson","fromEmail":"jidanni@jidanni.org","sentAt":"2017-07-07T15:57:14Z","receivedAt":"2017-07-08T04:01:22Z","isPatch":false,"sender":{"key":"jidanni@jidanni.org","avatar":"https://gravatar.com/avatar/36568d4af4c8d3e71627ef3b8c8d00e39065b12f29676cccd38ced75e68fa2a6?d=mp&s=160"},"body":"Receiving objects: 100% (1003/1003), 1.15 MiB | 0 bytes/s, done.\nReceiving objects: 100% (1861/1861), 11.74 MiB | 4.58 MiB/s, done.\nReceiving objects: 100% (474/474), 160.72 KiB | 0 bytes/s, done.\nReceiving objects: 100% (7190/7190), 26.02 MiB | 6.53 MiB/s, done.\n\nIf the connection is too fast to calculate, please report\n∞ bytes/s or\ninf bytes/s or\n? bytes/s or\nanything but 0 bytes/s, which means nothing (transmitted.)\n"},{"id":"323999","messageId":"2ac080ed-57aa-5492-8887-4421c50cf3cd@web.de","threadId":"46327","inReplyTo":"87lgo02qat.fsf@jidanni.org","subject":"Re: 0 bytes/s vs. ∞ bytes/s","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2017-07-08T16:43:42Z","receivedAt":"2017-07-08T16:44:05Z","isPatch":false,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Am 07.07.2017 um 17:57 schrieb 積丹尼 Dan Jacobson:\n> Receiving objects: 100% (1003/1003), 1.15 MiB | 0 bytes/s, done.\n> Receiving objects: 100% (1861/1861), 11.74 MiB | 4.58 MiB/s, done.\n> Receiving objects: 100% (474/474), 160.72 KiB | 0 bytes/s, done.\n> Receiving objects: 100% (7190/7190), 26.02 MiB | 6.53 MiB/s, done.\n> \n> If the connection is too fast to calculate, please report\n> ∞ bytes/s or\n> inf bytes/s or\n> ? bytes/s or\n> anything but 0 bytes/s, which means nothing (transmitted.)\n\nI don't know your actual transfer rate, but I would guess it's closer to\nzero than to infinity. :)\n\nHow about this, though:\n\n-- >8 --\nSubject: [PATCH] progress: show overall rate in last update\n\nThe values in struct throughput are only updated every 0.5 seconds.  If\nwe're all done before that time span then the final update will show a\nrate of 0 bytes/s, which is misleading if some bytes had been handled.\nRemember the start time and show the total throughput instead.\n\nAnd avoid division by zero by enforcing a minimum time span value of 1\n(unit: 1/1024th of a second).  That makes the resulting rate an\nunderestimation, but it's closer to the actual value than the currently\nshown 0 bytes/s.\n\nReported-by: 積丹尼 Dan Jacobson <jidanni@jidanni.org>\nSigned-off-by: Rene Scharfe <l.s.r@web.de>\n---\n progress.c | 8 ++++++--\n 1 file changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git a/progress.c b/progress.c\nindex 29378caa05..73e36d4a42 100644\n--- a/progress.c\n+++ b/progress.c\n@@ -36,6 +36,7 @@ struct progress {\n \tunsigned delay;\n \tunsigned delayed_percent_treshold;\n \tstruct throughput *throughput;\n+\tuint64_t start_ns;\n };\n \n static volatile sig_atomic_t progress_update;\n@@ -221,6 +222,7 @@ struct progress *start_progress_delay(const char *title, unsigned total,\n \tprogress->delayed_percent_treshold = percent_treshold;\n \tprogress->delay = delay;\n \tprogress->throughput = NULL;\n+\tprogress->start_ns = getnanotime();\n \tset_progress_signal();\n \treturn progress;\n }\n@@ -247,8 +249,10 @@ void stop_progress_msg(struct progress **p_progress, const char *msg)\n \t\tstruct throughput *tp = progress->throughput;\n \n \t\tif (tp) {\n-\t\t\tunsigned int rate = !tp->avg_misecs ? 0 :\n-\t\t\t\t\ttp->avg_bytes / tp->avg_misecs;\n+\t\t\tuint64_t now_ns = getnanotime();\n+\t\t\tunsigned int misecs, rate;\n+\t\t\tmisecs = ((now_ns - progress->start_ns) * 4398) >> 32;\n+\t\t\trate = tp->curr_total / (misecs ? misecs : 1);\n \t\t\tthroughput_string(&tp->display, tp->curr_total, rate);\n \t\t}\n \t\tprogress_update = 1;\n-- \n2.13.2\n"},{"id":"324001","messageId":"87eftqiv5a.fsf@jidanni.org","threadId":"46327","inReplyTo":"87lgo02qat.fsf@jidanni.org","subject":"Re: 0 bytes/s vs. ∞ bytes/s","fromName":"積丹尼 Dan Jacobson","fromEmail":"jidanni@jidanni.org","sentAt":"2017-07-08T19:30:25Z","receivedAt":"2017-07-08T19:30:34Z","isPatch":false,"sender":{"key":"jidanni@jidanni.org","avatar":"https://gravatar.com/avatar/36568d4af4c8d3e71627ef3b8c8d00e39065b12f29676cccd38ced75e68fa2a6?d=mp&s=160"},"body":"RS> Subject: [PATCH] progress: show overall rate in last update\nRS> Reported-by: 積丹尼 Dan Jacobson <jidanni@jidanni.org>\nRS> Signed-off-by: Rene Scharfe <l.s.r@web.de>\nThanks!\n"}]}