diff options
author | Karsten Blees <karsten.blees@gmail.com> | 2014-07-12 02:07:36 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-07-13 21:25:21 -0700 |
commit | 132d41e69a460f1bb72ba9eb41c513c42d9a8532 (patch) | |
tree | 524ff5ec7ba092027d34f188cf93648b80c4078b /wt-status.c | |
parent | 578da0391a7958510b960eaf1ef30d13e791554e (diff) | |
download | git-132d41e69a460f1bb72ba9eb41c513c42d9a8532.tar.gz |
wt-status: simplify performance measurement by using getnanotime()
Calculating duration from a single uint64_t is simpler than from a struct
timeval. Change performance measurement for 'advice.statusuoption' from
gettimeofday() to getnanotime().
Also initialize t_begin to prevent uninitialized variable warning.
Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'wt-status.c')
-rw-r--r-- | wt-status.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/wt-status.c b/wt-status.c index 318a191238..dfdc018f1b 100644 --- a/wt-status.c +++ b/wt-status.c @@ -574,14 +574,11 @@ static void wt_status_collect_untracked(struct wt_status *s) { int i; struct dir_struct dir; - struct timeval t_begin; + uint64_t t_begin = getnanotime(); if (!s->show_untracked_files) return; - if (advice_status_u_option) - gettimeofday(&t_begin, NULL); - memset(&dir, 0, sizeof(dir)); if (s->show_untracked_files != SHOW_ALL_UNTRACKED_FILES) dir.flags |= @@ -612,13 +609,8 @@ static void wt_status_collect_untracked(struct wt_status *s) free(dir.ignored); clear_directory(&dir); - if (advice_status_u_option) { - struct timeval t_end; - gettimeofday(&t_end, NULL); - s->untracked_in_ms = - (uint64_t)t_end.tv_sec * 1000 + t_end.tv_usec / 1000 - - ((uint64_t)t_begin.tv_sec * 1000 + t_begin.tv_usec / 1000); - } + if (advice_status_u_option) + s->untracked_in_ms = (getnanotime() - t_begin) / 1000000; } void wt_status_collect(struct wt_status *s) |