[PATCH] smbclient download status bar
David Collier-Brown
David.Collier-Brown at Sun.COM
Sun Nov 20 14:51:44 GMT 2005
If you grab a time at the very beginning of the download,
preferably before opening the file,and another at the
first write, then with the data you already have you can
report latency and response time as well as throughput.
Latency (delay before sending the first byte)
and total response time can be used for capacity
planning and performance tuning.
--dave (a performance nerd) c-b
Nick Hay wrote:
> This quick hack prints a status bar when you download files via smbclient:
>
> 4515840 of 263783900 bytes read (1.7% done)
>
> -- Nick Hay
>
> --- source/client/client.c.orig 2005-11-20 14:14:09.000000000 +1300
> +++ source/client/client.c 2005-11-20 15:26:14.000000000 +1300
> @@ -790,6 +790,9 @@
> return 1;
> }
>
> + char statustext[256];
> + statustext[0] = 0;
> +
> while (1) {
> int n = cli_read(targetcli, fnum, data, nread + start,
> read_size);
>
> @@ -803,7 +806,26 @@
> }
>
> nread += n;
> +
> + // erase previous status text and print new
> + char *p = statustext;
> + while (*p != 0) {
> + *p = '\b';
> + p++;
> + }
> + x_fprintf(dbf, statustext);
> +
> + snprintf(statustext, 256, "%i of %i bytes read (%2.1f%% done)",
> + (int)nread,
> (int)size, (double)nread*100/(int)size);
> + x_fprintf(dbf, "%s", statustext);
> + x_fflush(dbf);
> + }
> + char *p = statustext;
> + while (*p != 0) {
> + *p = '\b';
> + p++;
> }
> + x_fprintf(dbf, statustext);
>
> if (nread + start < size) {
> DEBUG (0, ("Short read when getting file %s. Only got
> %ld bytes.\n",
>
--
David Collier-Brown, | Always do right. This will gratify
Sun Microsystems, Toronto | some people and astonish the rest
davecb at canada.sun.com | -- Mark Twain
(416) 263-5733 (x65733) |
More information about the samba-technical
mailing list