Skip to content

Instantly share code, notes, and snippets.

@yoku0825
Created November 26, 2015 10:42
Show Gist options
  • Save yoku0825/3ca93369bbb88af3f26c to your computer and use it in GitHub Desktop.
Save yoku0825/3ca93369bbb88af3f26c to your computer and use it in GitHub Desktop.
*** client/mysql.cc.orig 2015-09-18 23:24:43.000000000 +0900
--- client/mysql.cc 2015-11-26 19:42:19.469000382 +0900
***************
*** 1128,1130 ****
static void mysql_end_timer(ulong start_time,char *buff);
! static void nice_time(double sec,char *buff,bool part_second);
extern "C" sig_handler mysql_end(int sig);
--- 1128,1130 ----
static void mysql_end_timer(ulong start_time,char *buff);
! static void nice_time(ulong sec,char *buff,bool part_second);
extern "C" sig_handler mysql_end(int sig);
***************
*** 5014,5016 ****
{
! nice_time((double) sec,buff,0);
tee_puts(buff, stdout); /* print nice time */
--- 5014,5016 ----
{
! nice_time((double) sec / 1000000,buff,0);
tee_puts(buff, stdout); /* print nice time */
***************
*** 5309,5312 ****
#else
! struct tms tms_tmp;
! return times(&tms_tmp);
#endif
--- 5309,5313 ----
#else
! struct timeval tv;
! gettimeofday(&tv, NULL);
! return (tv.tv_sec * 1000000) + tv.tv_usec;
#endif
***************
*** 5320,5328 ****
*/
! static void nice_time(double sec,char *buff,bool part_second)
{
ulong tmp;
! if (sec >= 3600.0*24)
{
! tmp=(ulong) floor(sec/(3600.0*24));
! sec-=3600.0*24*tmp;
buff=int10_to_str((long) tmp, buff, 10);
--- 5321,5329 ----
*/
! static void nice_time(ulong usec,char *buff,bool part_second)
{
ulong tmp;
! if (usec >= 3600.0*1000000*24)
{
! tmp=(ulong) floor(usec/(3600.0*1000000*24));
! usec-=3600.0*10000000*24*tmp;
buff=int10_to_str((long) tmp, buff, 10);
***************
*** 5330,5335 ****
}
! if (sec >= 3600.0)
{
! tmp=(ulong) floor(sec/3600.0);
! sec-=3600.0*tmp;
buff=int10_to_str((long) tmp, buff, 10);
--- 5331,5336 ----
}
! if (usec >= 3600.0 * 1000000)
{
! tmp=(ulong) floor(usec/(3600.0 * 1000000));
! usec-=3600.0*1000000*tmp;
buff=int10_to_str((long) tmp, buff, 10);
***************
*** 5337,5342 ****
}
! if (sec >= 60.0)
{
! tmp=(ulong) floor(sec/60.0);
! sec-=60.0*tmp;
buff=int10_to_str((long) tmp, buff, 10);
--- 5338,5343 ----
}
! if (usec >= 60.0 * 1000000)
{
! tmp=(ulong) floor(usec/(60.0 * 1000000));
! usec-=60.0*1000000*tmp;
buff=int10_to_str((long) tmp, buff, 10);
***************
*** 5345,5349 ****
if (part_second)
! sprintf(buff,"%.2f sec",sec);
else
! sprintf(buff,"%d sec",(int) sec);
}
--- 5346,5350 ----
if (part_second)
! sprintf(buff,"%.6f sec",(double)usec / 1000000);
else
! sprintf(buff,"%d sec",(int) usec / 1000000);
}
***************
*** 5353,5356 ****
{
! nice_time((double) (start_timer() - start_time) /
! CLOCKS_PER_SEC,buff,1);
}
--- 5354,5356 ----
{
! nice_time(start_timer() - start_time,buff,1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment