Branch data Line data Source code
1 : : #include "precizer.h"
2 : :
3 : : /**
4 : : * @brief Print traversal elapsed time and effective hashing throughput.
5 : : *
6 : : * Uses total_hashing_elapsed_ns and total_hashed_bytes from
7 : : * TraversalSummary.
8 : : *
9 : : * @param summary Traversal timing and hashing counters from file_list().
10 : : */
11 : 343 : void show_elapsed(const TraversalSummary *summary)
12 : : {
13 : : // Don't do anything
14 [ + + ]: 343 : if(config->compare == true)
15 : : {
16 : 166 : return;
17 : : }
18 : :
19 [ + - + + ]: 263 : if(summary->stats_only_pass == false && summary->at_least_one_file_was_shown == false)
20 : : {
21 : 86 : return;
22 : : }
23 : :
24 : 177 : long long int total_runtime_ns = cur_time_monotonic_ns() - config->app_start_time_ns;
25 : :
26 [ - + ]: 177 : if(total_runtime_ns < 0LL)
27 : : {
28 : 0 : total_runtime_ns = 0LL;
29 : : }
30 : :
31 : : static const char *const rate_na = "n/a";
32 : : static const char *const rate_less_than_1bps = "less than 1B/s";
33 : 354 : const bool perform_file_hashing = config->dry_run == false
34 [ + + + + ]: 177 : || config->dry_run_with_checksums == true;
35 : :
36 : : // Sum of per-file hashing time collected in sha512sum() during file_list().
37 : 177 : long long int elapsed_ns = summary->total_hashing_elapsed_ns;
38 : :
39 [ - + ]: 177 : if(elapsed_ns < 0LL)
40 : : {
41 : 0 : elapsed_ns = 0LL;
42 : : }
43 : :
44 : 177 : char total_runtime_string[50] = {0};
45 : 177 : (void)form_date_r(total_runtime_ns,FULL_VIEW,total_runtime_string,sizeof(total_runtime_string));
46 : :
47 : 177 : char elapsed_string[50] = {0};
48 : 177 : (void)form_date_r(elapsed_ns,FULL_VIEW,elapsed_string,sizeof(elapsed_string));
49 : :
50 : 177 : char hashed_string[50] = {0};
51 : 177 : const char *hashed = rate_na;
52 : 177 : const char *rate = rate_na;
53 : 177 : const char *suffix = "";
54 : :
55 [ + + ]: 177 : if(perform_file_hashing == true)
56 : : {
57 : 165 : (void)bkbmbgbtbpbeb_r(summary->total_hashed_bytes,MAJOR_VIEW,hashed_string,sizeof(hashed_string));
58 : 165 : hashed = hashed_string;
59 : :
60 [ + + ]: 165 : if(elapsed_ns > 0LL)
61 : : {
62 : 147 : long double bytes_per_second = ((long double)summary->total_hashed_bytes * 1000000000.0L) / (long double)elapsed_ns;
63 : :
64 [ - + ]: 147 : if(bytes_per_second < 1.0L)
65 : : {
66 : 0 : rate = rate_less_than_1bps;
67 : : } else {
68 : 147 : size_t speed_value = (size_t)bytes_per_second;
69 : 147 : rate = bkbmbgbtbpbeb(speed_value,MAJOR_VIEW);
70 : 147 : suffix = "/s";
71 : : }
72 : : }
73 : : }
74 : :
75 : 177 : slog(EVERY,"Total runtime: %s, elapsed time: %s, hashed: %s, hashing rate: %s%s\n",total_runtime_string,elapsed_string,hashed,rate,suffix);
76 : : }
|