{"thread":{"id":"21234","subject":"[PATCH] change throughput display units with fast links","startedAt":"2009-10-14T03:02:04Z","lastAt":"2009-10-14T09:13:08Z","messageCount":3,"participants":["Nicolas Pitre","Johannes Sixt","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"124920","messageId":"alpine.LFD.2.00.0910132256280.20122@xanadu.home","threadId":"21234","inReplyTo":null,"subject":"[PATCH] change throughput display units with fast links","fromName":"Nicolas Pitre","fromEmail":"nico@fluxnic.net","sentAt":"2009-10-14T03:02:04Z","receivedAt":"2009-10-14T03:02:04Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"Switch to MiB/s when the connection is fast enough (i.e. on a LAN).\n\nSigned-off-by: Nicolas Pitre <nico@fluxnic.net>\n---\ndiff --git a/progress.c b/progress.c\nindex 132ed95..3971f49 100644\n--- a/progress.c\n+++ b/progress.c\n@@ -131,7 +131,13 @@ static void throughput_string(struct throughput *tp, off_t total,\n \t} else {\n \t\tl -= snprintf(tp->display, l, \", %u bytes\", (int)total);\n \t}\n-\tif (rate)\n+\n+\tif (rate > 1 << 10) {\n+\t\tint x = rate + 5;  /* for rounding */\n+\t\tsnprintf(tp->display + sizeof(tp->display) - l, l,\n+\t\t\t \" | %u.%2.2u MiB/s\",\n+\t\t\t x >> 10, ((x & ((1 << 10) - 1)) * 100) >> 10);\n+\t} else if (rate)\n \t\tsnprintf(tp->display + sizeof(tp->display) - l, l,\n \t\t\t \" | %u KiB/s\", rate);\n }\n"},{"id":"124947","messageId":"4AD578BD.7080201@viscovery.net","threadId":"21234","inReplyTo":"alpine.LFD.2.00.0910132256280.20122@xanadu.home","subject":"Re: [PATCH] change throughput display units with fast links","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2009-10-14T07:07:41Z","receivedAt":"2009-10-14T07:07:41Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Nicolas Pitre schrieb:\n> +\tif (rate > 1 << 10) {\n> +\t\tint x = rate + 5;  /* for rounding */\n> +\t\tsnprintf(tp->display + sizeof(tp->display) - l, l,\n> +\t\t\t \" | %u.%2.2u MiB/s\",\n\nShouldn't the fractional part be \"%02.2u\" (leading zeros instead of blanks)?\n\n> +\t\t\t x >> 10, ((x & ((1 << 10) - 1)) * 100) >> 10);\n> +\t} else if (rate)\n>  \t\tsnprintf(tp->display + sizeof(tp->display) - l, l,\n>  \t\t\t \" | %u KiB/s\", rate);\n>  }\n\n-- Hannes\n"},{"id":"124952","messageId":"7viqeifie3.fsf@alter.siamese.dyndns.org","threadId":"21234","inReplyTo":"4AD578BD.7080201@viscovery.net","subject":"Re: [PATCH] change throughput display units with fast links","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-10-14T09:13:08Z","receivedAt":"2009-10-14T09:13:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j.sixt@viscovery.net> writes:\n\n> Nicolas Pitre schrieb:\n>> +\tif (rate > 1 << 10) {\n>> +\t\tint x = rate + 5;  /* for rounding */\n>> +\t\tsnprintf(tp->display + sizeof(tp->display) - l, l,\n>> +\t\t\t \" | %u.%2.2u MiB/s\",\n>\n> Shouldn't the fractional part be \"%02.2u\" (leading zeros instead of blanks)?\n>\n>> +\t\t\t x >> 10, ((x & ((1 << 10) - 1)) * 100) >> 10);\n>> +\t} else if (rate)\n>>  \t\tsnprintf(tp->display + sizeof(tp->display) - l, l,\n>>  \t\t\t \" | %u KiB/s\", rate);\n>>  }\n>\n> -- Hannes\n\nJudging from the surrounding existing code, I do not think so.\n\n    $ cat <<\\EOF >j.c\n    #include <stdio.h>\n\n    int main(int ac, char **av)\n    {\n            printf(\"%u.%2.2u\\n\", 4, 5);\n            return 0;\n    }\n    EOF\n    $ gcc -o j j.c && ./j\n    4.05\n"}]}