summaryrefslogtreecommitdiffstats
path: root/bin/dd/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'bin/dd/misc.c')
-rw-r--r--bin/dd/misc.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/bin/dd/misc.c b/bin/dd/misc.c
index 61f843b..eb1227b 100644
--- a/bin/dd/misc.c
+++ b/bin/dd/misc.c
@@ -40,14 +40,15 @@ static char sccsid[] = "@(#)misc.c 8.3 (Berkeley) 4/2/94";
__FBSDID("$FreeBSD$");
#include <sys/types.h>
-#include <sys/time.h>
+#include <err.h>
#include <errno.h>
#include <inttypes.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <time.h>
#include <unistd.h>
#include "dd.h"
@@ -56,16 +57,21 @@ __FBSDID("$FreeBSD$");
void
summary(void)
{
- struct timeval tv;
- double secs;
+ struct timespec end, ts_res;
+ double secs, res;
if (ddflags & C_NOINFO)
return;
- (void)gettimeofday(&tv, NULL);
- secs = tv.tv_sec + tv.tv_usec * 1e-6 - st.start;
- if (secs < 1e-6)
- secs = 1e-6;
+ if (clock_gettime(CLOCK_MONOTONIC, &end))
+ err(1, "clock_gettime");
+ if (clock_getres(CLOCK_MONOTONIC, &ts_res))
+ err(1, "clock_getres");
+ secs = (end.tv_sec - st.start.tv_sec) + \
+ (end.tv_nsec - st.start.tv_nsec) * 1e-9;
+ res = ts_res.tv_sec + ts_res.tv_nsec * 1e-9;
+ if (secs < res)
+ secs = res;
(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);
OpenPOWER on IntegriCloud