Skip to content

Commit 2cc73ed

Browse files
committed
Display time statistics for casync extract
This commit adds the following lines to casync extract statistics: Time spent seeding: 2min 29.401s (82%) Time spent decoding: 31.178s (17%) Total extract time: 3min 631ms Signed-off-by: Arnaud Rebillout <[email protected]>
1 parent ef9d96c commit 2cc73ed

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/casync-tool.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,7 @@ static int verbose_print_done_extract(CaSync *s) {
974974
uint64_t n_local_requests = UINT64_MAX, n_seed_requests = UINT64_MAX, n_remote_requests = UINT64_MAX;
975975
uint64_t n_local_bytes = UINT64_MAX, n_seed_bytes = UINT64_MAX, n_remote_bytes = UINT64_MAX;
976976
uint64_t total_requests = 0, total_bytes = 0;
977+
uint64_t nsec = 0, runtime_nsec = 0;
977978
int r;
978979

979980
if (!arg_verbose)
@@ -1082,6 +1083,34 @@ static int verbose_print_done_extract(CaSync *s) {
10821083
format_bytes(buffer, sizeof(buffer), n_remote_bytes),
10831084
total_bytes > 0 ? n_remote_bytes * 100U / total_bytes : 0);
10841085

1086+
r = ca_sync_get_runtime_nsec(s, &runtime_nsec);
1087+
if (!IN_SET(r, -ENODATA)) {
1088+
if (r < 0)
1089+
return log_error_errno(r, "Failed to determine runtime: %m");
1090+
}
1091+
1092+
r = ca_sync_get_seed_seeding_time_nsec(s, &nsec);
1093+
if (!IN_SET(r, -ENODATA, -ENOTTY)) {
1094+
if (r < 0)
1095+
return log_error_errno(r, "Failed to determine seeding time: %m");
1096+
1097+
log_info("Time spent seeding: %s (%" PRIu64 "%%)",
1098+
format_timespan(buffer, sizeof(buffer), nsec, NSEC_PER_MSEC),
1099+
runtime_nsec > 0 ? nsec * 100U / runtime_nsec : 0);
1100+
}
1101+
1102+
r = ca_sync_get_decoding_time_nsec(s, &nsec);
1103+
if (!IN_SET(r, -ENODATA, -ENOTTY)) {
1104+
if (r < 0)
1105+
return log_error_errno(r, "Failed to determine decoding time: %m");
1106+
1107+
log_info("Time spent decoding: %s (%" PRIu64 "%%)",
1108+
format_timespan(buffer, sizeof(buffer), nsec, NSEC_PER_MSEC),
1109+
runtime_nsec > 0 ? nsec * 100U / runtime_nsec : 0);
1110+
}
1111+
1112+
log_info("Total extract time: %s", format_timespan(buffer, sizeof(buffer), runtime_nsec, NSEC_PER_MSEC));
1113+
10851114
return 1;
10861115
}
10871116

0 commit comments

Comments
 (0)