-
- if (!am_sender) {
- int64 r;
- stats.total_written = read_longint(f);
- r = read_longint(f);
- stats.total_size = read_longint(f);
- stats.total_read = r;
- }
-
- if (do_stats) {
- rprintf(FINFO,"\nNumber of files: %d\n", stats.num_files);
- rprintf(FINFO,"Number of files transferred: %d\n",
- stats.num_transferred_files);
- rprintf(FINFO,"Total file size: %.0f bytes\n",
- (double)stats.total_size);
- rprintf(FINFO,"Total transferred file size: %.0f bytes\n",
- (double)stats.total_transferred_size);
- rprintf(FINFO,"Literal data: %.0f bytes\n",
- (double)stats.literal_data);
- rprintf(FINFO,"Matched data: %.0f bytes\n",
- (double)stats.matched_data);
- rprintf(FINFO,"File list size: %d\n", stats.flist_size);
- rprintf(FINFO,"Total bytes written: %.0f\n",
- (double)stats.total_written);
- rprintf(FINFO,"Total bytes read: %.0f\n\n",
- (double)stats.total_read);
+
+ if (am_server) {
+ if (am_sender) {
+ write_varlong30(f, total_read, 3);
+ write_varlong30(f, total_written, 3);
+ write_varlong30(f, stats.total_size, 3);
+ if (protocol_version >= 29) {
+ write_varlong30(f, stats.flist_buildtime, 3);
+ write_varlong30(f, stats.flist_xfertime, 3);
+ }
+ }
+ return;
+ }
+
+ /* this is the client */
+
+ if (f < 0 && !am_sender) /* e.g. when we got an empty file list. */
+ ;
+ else if (!am_sender) {
+ /* Read the first two in opposite order because the meaning of
+ * read/write swaps when switching from sender to receiver. */
+ total_written = read_varlong30(f, 3);
+ total_read = read_varlong30(f, 3);
+ stats.total_size = read_varlong30(f, 3);
+ if (protocol_version >= 29) {
+ stats.flist_buildtime = read_varlong30(f, 3);
+ stats.flist_xfertime = read_varlong30(f, 3);
+ }
+ } else if (write_batch) {
+ /* The --read-batch process is going to be a client
+ * receiver, so we need to give it the stats. */
+ write_varlong30(batch_fd, total_read, 3);
+ write_varlong30(batch_fd, total_written, 3);
+ write_varlong30(batch_fd, stats.total_size, 3);
+ if (protocol_version >= 29) {
+ write_varlong30(batch_fd, stats.flist_buildtime, 3);
+ write_varlong30(batch_fd, stats.flist_xfertime, 3);
+ }
+ }
+}
+
+static void output_summary(void)
+{
+ if (INFO_GTE(STATS, 2)) {
+ rprintf(FCLIENT, "\n");
+ rprintf(FINFO,"Number of files: %d\n", stats.num_files);
+ rprintf(FINFO,"Number of files transferred: %d\n",
+ stats.num_transferred_files);
+ rprintf(FINFO,"Total file size: %s bytes\n",
+ big_num(stats.total_size, human_readable));
+ rprintf(FINFO,"Total transferred file size: %s bytes\n",
+ big_num(stats.total_transferred_size, human_readable));
+ rprintf(FINFO,"Literal data: %s bytes\n",
+ big_num(stats.literal_data, human_readable));
+ rprintf(FINFO,"Matched data: %s bytes\n",
+ big_num(stats.matched_data, human_readable));
+ rprintf(FINFO,"File list size: %s\n",
+ big_num(stats.flist_size, human_readable));
+ if (stats.flist_buildtime) {
+ rprintf(FINFO,
+ "File list generation time: %.3f seconds\n",
+ (double)stats.flist_buildtime / 1000);
+ rprintf(FINFO,
+ "File list transfer time: %.3f seconds\n",
+ (double)stats.flist_xfertime / 1000);
+ }
+ rprintf(FINFO,"Total bytes sent: %s\n",
+ big_num(total_written, human_readable));
+ rprintf(FINFO,"Total bytes received: %s\n",
+ big_num(total_read, human_readable));
+ }
+
+ if (INFO_GTE(STATS, 1)) {
+ rprintf(FCLIENT, "\n");
+ rprintf(FINFO,
+ "sent %s bytes received %s bytes %s bytes/sec\n",
+ big_num(total_written, human_readable),
+ big_num(total_read, human_readable),
+ human_dnum((total_written + total_read)/(0.5 + (endtime - starttime)), 2));
+ rprintf(FINFO, "total size is %s speedup is %.2f%s\n",
+ big_num(stats.total_size, human_readable),
+ (double)stats.total_size / (total_written+total_read),
+ write_batch < 0 ? " (BATCH ONLY)" : dry_run ? " (DRY RUN)" : "");