forked from enlightenment/efl
evil: Remove unnecessary delay for evil startup
Apparently there were two loops intended for an older (and dropped off) implementation of `gettimeofday`. This patch simplifies the code removing these loops and significantly lowering evil startup. Without this patch `ecore-suite`, `efl-app` and `evas-suite` gets timeout in Windows: ``` 25/29 ecore-suite TIMEOUT 30.12s 26/29 efl-app TIMEOUT 30.14s ... 29/29 evas-suite TIMEOUT 60.07s ``` Reviewed-by: Vincent Torri <vincent.torri@gmail.com> Reviewed-by: Stefan Schmidt <stefan@datenfreihafen.org> Differential Revision: https://phab.enlightenment.org/D12064
This commit is contained in:
parent
a25bc7e769
commit
f09080fad5
|
@ -11,19 +11,14 @@ static int _evil_init_count = 0;
|
||||||
|
|
||||||
extern LONGLONG _evil_time_freq;
|
extern LONGLONG _evil_time_freq;
|
||||||
extern LONGLONG _evil_time_count;
|
extern LONGLONG _evil_time_count;
|
||||||
extern long _evil_time_second;
|
|
||||||
|
|
||||||
extern DWORD _evil_tls_index;
|
extern DWORD _evil_tls_index;
|
||||||
|
|
||||||
long _evil_systemtime_to_time(SYSTEMTIME st);
|
|
||||||
|
|
||||||
int
|
int
|
||||||
evil_init(void)
|
evil_init(void)
|
||||||
{
|
{
|
||||||
SYSTEMTIME st;
|
|
||||||
LARGE_INTEGER freq;
|
LARGE_INTEGER freq;
|
||||||
LARGE_INTEGER count;
|
LARGE_INTEGER count;
|
||||||
WORD second = 59;
|
|
||||||
|
|
||||||
if (++_evil_init_count != 1)
|
if (++_evil_init_count != 1)
|
||||||
return _evil_init_count;
|
return _evil_init_count;
|
||||||
|
@ -39,30 +34,11 @@ evil_init(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!QueryPerformanceFrequency(&freq))
|
QueryPerformanceFrequency(&freq);
|
||||||
return 0;
|
|
||||||
|
|
||||||
_evil_time_freq = freq.QuadPart;
|
_evil_time_freq = freq.QuadPart;
|
||||||
|
|
||||||
/* be sure that second + 1 != 0 */
|
QueryPerformanceCounter(&count);
|
||||||
while (second == 59)
|
|
||||||
{
|
|
||||||
GetSystemTime(&st);
|
|
||||||
second = st.wSecond;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* retrieve the tick corresponding to the time we retrieve above */
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
GetSystemTime(&st);
|
|
||||||
QueryPerformanceCounter(&count);
|
|
||||||
if (st.wSecond == second + 1)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
_evil_time_second = _evil_systemtime_to_time(st);
|
|
||||||
if (_evil_time_second < 0)
|
|
||||||
return --_evil_init_count;
|
|
||||||
|
|
||||||
_evil_time_count = count.QuadPart;
|
_evil_time_count = count.QuadPart;
|
||||||
|
|
||||||
|
|
|
@ -93,9 +93,8 @@
|
||||||
* @brief Initialize the Evil library.
|
* @brief Initialize the Evil library.
|
||||||
*
|
*
|
||||||
* This function initializes the Evil library. It must be called before
|
* This function initializes the Evil library. It must be called before
|
||||||
* using evil_time_get(), gettimeofday() or pipe(). It returns 0 on
|
* using evil_time_get() or pipe(). It returns 0 on failure, otherwise it
|
||||||
* failure, otherwise it returns the number of times it has already been
|
* returns the number of times it has already been called.
|
||||||
* called.
|
|
||||||
*
|
*
|
||||||
* When Evil is not used anymore, call evil_shutdown() to shut down
|
* When Evil is not used anymore, call evil_shutdown() to shut down
|
||||||
* the Evil library.
|
* the Evil library.
|
||||||
|
|
|
@ -17,34 +17,6 @@
|
||||||
|
|
||||||
LONGLONG _evil_time_freq;
|
LONGLONG _evil_time_freq;
|
||||||
LONGLONG _evil_time_count;
|
LONGLONG _evil_time_count;
|
||||||
long _evil_time_second;
|
|
||||||
|
|
||||||
|
|
||||||
long _evil_systemtime_to_time(SYSTEMTIME st);
|
|
||||||
|
|
||||||
long
|
|
||||||
_evil_systemtime_to_time(SYSTEMTIME st)
|
|
||||||
{
|
|
||||||
int days[] = {
|
|
||||||
-1, 30, 58, 89, 119, 150, 180, 211, 242, 272, 303, 333, 364
|
|
||||||
};
|
|
||||||
int day;
|
|
||||||
time_t t;
|
|
||||||
|
|
||||||
st.wYear -= 1900;
|
|
||||||
if ((st.wYear < 70) || (st.wYear > 138))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
day = st.wDay + days[st.wMonth - 1];
|
|
||||||
|
|
||||||
if (!(st.wYear & 3) && (st.wMonth > 2) )
|
|
||||||
day++;
|
|
||||||
|
|
||||||
t = ((st.wYear - 70) * 365 + ((st.wYear - 1) >> 2) - 17 + day) * 24 + st.wHour;
|
|
||||||
t = (t * 60 + st.wMinute) * 60 + st.wSecond;
|
|
||||||
|
|
||||||
return (long)t;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Time related functions
|
* Time related functions
|
||||||
|
@ -58,7 +30,7 @@ evil_time_get(void)
|
||||||
|
|
||||||
QueryPerformanceCounter(&count);
|
QueryPerformanceCounter(&count);
|
||||||
|
|
||||||
return (double)_evil_time_second + (double)(count.QuadPart - _evil_time_count)/ (double)_evil_time_freq;
|
return (double)(count.QuadPart - _evil_time_count)/ (double)_evil_time_freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue