зеркало из https://github.com/github/ruby.git
* gc.c (getrusage_time): Returned effective value on Windows.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
608cb2ed32
Коммит
741cc67800
|
@ -1,3 +1,7 @@
|
|||
Tue Aug 12 18:51:29 2008 TAKAO Kouji <kouji@takao7.net>
|
||||
|
||||
* gc.c (getrusage_time): Returned effective value on Windows.
|
||||
|
||||
Tue Aug 12 18:51:11 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* transcode.c (rb_trans_open): free ts before raise.
|
||||
|
|
21
gc.c
21
gc.c
|
@ -119,6 +119,27 @@ getrusage_time(void)
|
|||
getrusage(RUSAGE_SELF, &usage);
|
||||
time = usage.ru_utime;
|
||||
return time.tv_sec + time.tv_usec * 1e-6;
|
||||
#elif defined _WIN32
|
||||
FILETIME creation_time, exit_time, kernel_time, user_time;
|
||||
ULARGE_INTEGER ui;
|
||||
LONG_LONG q;
|
||||
double t;
|
||||
|
||||
if (GetProcessTimes(GetCurrentProcess(),
|
||||
&creation_time, &exit_time, &kernel_time, &user_time) == 0)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
memcpy(&ui, &user_time, sizeof(FILETIME));
|
||||
q = ui.QuadPart / 10L;
|
||||
t = (DWORD)(q % 1000000L) * 1e-6;
|
||||
q /= 1000000L;
|
||||
#ifdef __GNUC__
|
||||
t += q;
|
||||
#else
|
||||
t += (double)(DWORD)(q >> 16) * (1 << 16);
|
||||
t += (DWORD)q & ~(~0 << 16);
|
||||
#endif
|
||||
#else
|
||||
return 0.0;
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче