From 3de807a14721ec9e963f1de4d4b805cdaf1212d6 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Fri, 14 Aug 2020 11:05:12 +0300 Subject: libglusterfs: add functions to calculate time difference Add gf_tvdiff() and gf_tsdiff() to calculate the difference between 'struct timeval' and 'struct timespec' values, use them where appropriate. Change-Id: I172be06ee84e99a1da76847c15e5ea3fbc059338 Signed-off-by: Dmitry Antipov Updates: #1002 --- glusterfsd/src/glusterfsd-mgmt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'glusterfsd/src') diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c index 793f27ab67f..eaf6796e4c3 100644 --- a/glusterfsd/src/glusterfsd-mgmt.c +++ b/glusterfsd/src/glusterfsd-mgmt.c @@ -629,7 +629,7 @@ glusterfs_volume_top_perf(const char *brick_path, dict_t *dict, goto out; } - time = (end.tv_sec - begin.tv_sec) * 1e6 + (end.tv_usec - begin.tv_usec); + time = gf_tvdiff(&begin, &end); throughput = total_blks / time; gf_log("glusterd", GF_LOG_INFO, "Throughput %.2f Mbps time %.2f secs " @@ -685,7 +685,7 @@ glusterfs_volume_top_perf(const char *brick_path, dict_t *dict, goto out; } - time = (end.tv_sec - begin.tv_sec) * 1e6 + (end.tv_usec - begin.tv_usec); + time = gf_tvdiff(&begin, &end); throughput = total_blks / time; gf_log("glusterd", GF_LOG_INFO, "Throughput %.2f Mbps time %.2f secs " -- cgit