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>
Karsten Blees committed
Jul 12, 2014 at 02:07 UTC
132d41e69a460f1bb72ba9eb41c513c42d9a8532
1 file changed
+3
-11
wt-status.c
+3
-11
@@ -574,14 +574,11 @@ static void wt_status_collect_untracked(struct wt_status *s)
574
{
575
int i;
576
struct dir_struct dir;
577
- struct timeval t_begin;
577
+ uint64_t t_begin = getnanotime();
578
579
if (!s->show_untracked_files)
580
return;
581
582
- if (advice_status_u_option)
583
- gettimeofday(&t_begin, NULL);
584
-
582
memset(&dir, 0, sizeof(dir));
583
if (s->show_untracked_files != SHOW_ALL_UNTRACKED_FILES)
584
dir.flags |=
@@ -612,13 +609,8 @@ static void wt_status_collect_untracked(struct wt_status *s)
609
free(dir.ignored);
610
clear_directory(&dir);
611
615
- if (advice_status_u_option) {
616
- struct timeval t_end;
617
- gettimeofday(&t_end, NULL);
618
- s->untracked_in_ms =
619
- (uint64_t)t_end.tv_sec * 1000 + t_end.tv_usec / 1000 -
620
- ((uint64_t)t_begin.tv_sec * 1000 + t_begin.tv_usec / 1000);
621
- }
612
+ if (advice_status_u_option)
613
+ s->untracked_in_ms = (getnanotime() - t_begin) / 1000000;
614
}
615
616
void wt_status_collect(struct wt_status *s)