From 71ea8b052dc469b8fca0965a0441f17fb7cb91a0 Mon Sep 17 00:00:00 2001 From: pengyiqiang Date: Fri, 15 Jul 2022 16:23:39 +0800 Subject: [PATCH] nshlib/nsh_ddcmd: calculate time difference with microsecond precision Signed-off-by: pengyiqiang --- nshlib/nsh_ddcmd.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nshlib/nsh_ddcmd.c b/nshlib/nsh_ddcmd.c index 0b05860db..288cdcc74 100644 --- a/nshlib/nsh_ddcmd.c +++ b/nshlib/nsh_ddcmd.c @@ -353,14 +353,15 @@ int cmd_dd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) elapsed = (((uint64_t)ts1.tv_sec * NSEC_PER_SEC) + ts1.tv_nsec); elapsed -= (((uint64_t)ts0.tv_sec * NSEC_PER_SEC) + ts0.tv_nsec); - elapsed /= NSEC_PER_MSEC; /* msec */ + elapsed /= NSEC_PER_USEC; /* usec */ total = ((uint64_t)dd.sector * (uint64_t)dd.sectsize); - nsh_output(vtbl, "%llu bytes copied, %u msec, ", + nsh_output(vtbl, "%llu bytes copied, %u usec, ", total, (unsigned int)elapsed); nsh_output(vtbl, "%u KB/s\n" , - (unsigned int)((double)total / (double)elapsed)); + (unsigned int)(((double)total / 1024) + / ((double)elapsed / USEC_PER_SEC))); #endif errout_with_outf: