diff options
Diffstat (limited to 'bin/dd/misc.c')
-rw-r--r-- | bin/dd/misc.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/bin/dd/misc.c b/bin/dd/misc.c index eb1227b..ea0f8d3 100644 --- a/bin/dd/misc.c +++ b/bin/dd/misc.c @@ -54,15 +54,12 @@ __FBSDID("$FreeBSD$"); #include "dd.h" #include "extern.h" -void -summary(void) +double +secs_elapsed(void) { struct timespec end, ts_res; double secs, res; - if (ddflags & C_NOINFO) - return; - if (clock_gettime(CLOCK_MONOTONIC, &end)) err(1, "clock_gettime"); if (clock_getres(CLOCK_MONOTONIC, &ts_res)) @@ -72,6 +69,20 @@ summary(void) res = ts_res.tv_sec + ts_res.tv_nsec * 1e-9; if (secs < res) secs = res; + + return (secs); +} + +void +summary(void) +{ + double secs; + + if (ddflags & C_NOINFO) + return; + + secs = secs_elapsed(); + (void)fprintf(stderr, "%ju+%ju records in\n%ju+%ju records out\n", st.in_full, st.in_part, st.out_full, st.out_part); |