From d5e46428075d86dbdc333d27951bb06cb4c11a32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Mon, 28 Nov 2016 07:45:52 +0100 Subject: [PATCH] More exact timing for mysql client based on my_timer_microseconds Based on suggestion from @grooverdan on https://github.com/mysql/mysql-server/pull/112 --- client/mysql.cc | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 46147e9..26758bc 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -35,6 +35,7 @@ #include #include #include +#include #ifndef __GNU_LIBRARY__ #define __GNU_LIBRARY__ // Skip warnings in getopt.h #endif @@ -5534,12 +5535,7 @@ void tee_putc(int c, FILE *file) static ulong start_timer(void) { -#if defined(_WIN32) - return clock(); -#else - struct tms tms_tmp; - return times(&tms_tmp); -#endif + return my_timer_microseconds(); } @@ -5550,6 +5546,7 @@ static ulong start_timer(void) */ static void nice_time(double sec,char *buff,bool part_second) { + sec = sec / 10000; ulong tmp; if (sec >= 3600.0*24) { @@ -5573,7 +5570,7 @@ static void nice_time(double sec,char *buff,bool part_second) buff=my_stpcpy(buff," min "); } if (part_second) - sprintf(buff,"%.2f sec",sec); + sprintf(buff,"%.3f sec",sec); else sprintf(buff,"%d sec",(int) sec); }