mirror of
https://github.com/MariaDB/server.git
synced 2025-01-30 18:41:56 +01:00
Fix for counting query time for Windows.
mysys/my_getsystime.c: Fix for counting query time for Windows. Added parenthesis just to make reading code easier. Fixed some comments.
This commit is contained in:
parent
082b0b04ad
commit
56e0d38d0b
1 changed files with 23 additions and 17 deletions
|
@ -35,9 +35,9 @@ ulonglong my_getsystime()
|
||||||
if (query_performance_frequency)
|
if (query_performance_frequency)
|
||||||
{
|
{
|
||||||
QueryPerformanceCounter(&t_cnt);
|
QueryPerformanceCounter(&t_cnt);
|
||||||
return (t_cnt.QuadPart / query_performance_frequency * 10000000+
|
return ((t_cnt.QuadPart / query_performance_frequency * 10000000) +
|
||||||
t_cnt.QuadPart % query_performance_frequency * 10000000/
|
(t_cnt.QuadPart % query_performance_frequency * 10000000 /
|
||||||
query_performance_frequency+query_performance_offset);
|
query_performance_frequency) + query_performance_offset);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
#elif defined(__NETWARE__)
|
#elif defined(__NETWARE__)
|
||||||
|
@ -108,7 +108,9 @@ ulonglong my_micro_time()
|
||||||
if (query_performance_frequency)
|
if (query_performance_frequency)
|
||||||
{
|
{
|
||||||
QueryPerformanceCounter((LARGE_INTEGER*) &newtime);
|
QueryPerformanceCounter((LARGE_INTEGER*) &newtime);
|
||||||
newtime/= (query_performance_frequency * 1000000);
|
return ((new_time / query_performance_frequency * 10000000) +
|
||||||
|
(new_time % query_performance_frequency * 10000000 /
|
||||||
|
query_performance_frequency));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
newtime= (GetTickCount() * 1000); /* GetTickCount only returns milliseconds */
|
newtime= (GetTickCount() * 1000); /* GetTickCount only returns milliseconds */
|
||||||
|
@ -117,7 +119,9 @@ ulonglong my_micro_time()
|
||||||
return gethrtime()/1000;
|
return gethrtime()/1000;
|
||||||
#else
|
#else
|
||||||
struct timeval t;
|
struct timeval t;
|
||||||
/* The following loop is here because gettimeofday may fail on some systems */
|
/*
|
||||||
|
The following loop is here because gettimeofday may fail on some systems
|
||||||
|
*/
|
||||||
while (gettimeofday(&t, NULL) != 0)
|
while (gettimeofday(&t, NULL) != 0)
|
||||||
{}
|
{}
|
||||||
newtime= (ulonglong)t.tv_sec * 1000000 + t.tv_usec;
|
newtime= (ulonglong)t.tv_sec * 1000000 + t.tv_usec;
|
||||||
|
@ -131,18 +135,18 @@ ulonglong my_micro_time()
|
||||||
|
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
my_micro_time_and_time()
|
my_micro_time_and_time()
|
||||||
time_arg Will be set to seconds since epoch (00:00:00 UTC, January 1,
|
time_arg Will be set to seconds since epoch (00:00:00 UTC,
|
||||||
1970)
|
January 1, 1970)
|
||||||
|
|
||||||
NOTES
|
NOTES
|
||||||
This function is to be useful when we need both the time and microtime.
|
This function is to be useful when we need both the time and microtime.
|
||||||
For example in MySQL this is used to get the query time start of a query and
|
For example in MySQL this is used to get the query time start of a query
|
||||||
to measure the time of a query (for the slow query log)
|
and to measure the time of a query (for the slow query log)
|
||||||
|
|
||||||
IMPLEMENTATION
|
IMPLEMENTATION
|
||||||
Value of time is as in time() call.
|
Value of time is as in time() call.
|
||||||
Value of microtime is same as my_micro_time(), which may be totally unrealated
|
Value of microtime is same as my_micro_time(), which may be totally
|
||||||
to time()
|
unrealated to time()
|
||||||
|
|
||||||
RETURN
|
RETURN
|
||||||
Value in microseconds from some undefined point in time
|
Value in microseconds from some undefined point in time
|
||||||
|
@ -160,13 +164,13 @@ ulonglong my_micro_time_and_time(time_t *time_arg)
|
||||||
newtime/= (query_performance_frequency * 1000000);
|
newtime/= (query_performance_frequency * 1000000);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
newtime= (GetTickCount() * 1000); /* GetTickCount only returns milliseconds */
|
newtime= (GetTickCount() * 1000); /* GetTickCount only returns millisec. */
|
||||||
(void) time(time_arg);
|
(void) time(time_arg);
|
||||||
return newtime;
|
return newtime;
|
||||||
#elif defined(HAVE_GETHRTIME)
|
#elif defined(HAVE_GETHRTIME)
|
||||||
/*
|
/*
|
||||||
Solaris has a very slow time() call. We optimize this by using the very fast
|
Solaris has a very slow time() call. We optimize this by using the very
|
||||||
gethrtime() call and only calling time() every 1/2 second
|
fast gethrtime() call and only calling time() every 1/2 second
|
||||||
*/
|
*/
|
||||||
static hrtime_t prev_gethrtime= 0;
|
static hrtime_t prev_gethrtime= 0;
|
||||||
static time_t cur_time= 0;
|
static time_t cur_time= 0;
|
||||||
|
@ -184,7 +188,9 @@ ulonglong my_micro_time_and_time(time_t *time_arg)
|
||||||
return cur_gethrtime/1000;
|
return cur_gethrtime/1000;
|
||||||
#else
|
#else
|
||||||
struct timeval t;
|
struct timeval t;
|
||||||
/* The following loop is here because gettimeofday may fail on some systems */
|
/*
|
||||||
|
The following loop is here because gettimeofday may fail on some systems
|
||||||
|
*/
|
||||||
while (gettimeofday(&t, NULL) != 0)
|
while (gettimeofday(&t, NULL) != 0)
|
||||||
{}
|
{}
|
||||||
*time_arg= t.tv_sec;
|
*time_arg= t.tv_sec;
|
||||||
|
@ -203,8 +209,8 @@ ulonglong my_micro_time_and_time(time_t *time_arg)
|
||||||
|
|
||||||
NOTES
|
NOTES
|
||||||
This function returns the current time. The microtime argument is only used
|
This function returns the current time. The microtime argument is only used
|
||||||
if my_micro_time() uses a function that can safely be converted to the current
|
if my_micro_time() uses a function that can safely be converted to the
|
||||||
time.
|
current time.
|
||||||
|
|
||||||
RETURN
|
RETURN
|
||||||
current time
|
current time
|
||||||
|
|
Loading…
Add table
Reference in a new issue