Commit 1d5ba9bb authored by sof's avatar sof
Browse files

[project @ 2001-11-20 21:39:12 by sof]

getTimes (win32): Win9x OSes don't provide per-process timing data, so
GetProcessTimes() doesn't do anything interesting. So, resort to using
system-time instead to measure user/process time iff running under Win9x.
(the precision is not as good, deltas were ~6 millisecs when testing
on a Win98 box, but it's better than nothing).

This change should make profiling on Win9x boxes finally work.
parent 17035366
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* $Id: Stats.c,v 1.34 2001/11/05 05:12:55 sof Exp $ * $Id: Stats.c,v 1.35 2001/11/20 21:39:12 sof Exp $
* *
* (c) The GHC Team, 1998-1999 * (c) The GHC Team, 1998-1999
* *
...@@ -124,24 +124,53 @@ static nat pageFaults(void); ...@@ -124,24 +124,53 @@ static nat pageFaults(void);
static void static void
getTimes(void) getTimes(void)
{ {
FILETIME creationTime, exitTime, kernelTime, userTime; static int is_win9x = -1;
FILETIME creationTime, exitTime, userTime, kernelTime = {0,0};
long long int kT, uT; long long int kT, uT;
if (is_win9x < 0) {
/* figure out whether we're on a Win9x box or not. */
OSVERSIONINFO oi;
BOOL b;
/* Need to init the size field first.*/
oi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
b = GetVersionEx(&oi);
is_win9x = ( (b && (oi.dwPlatformId & VER_PLATFORM_WIN32_WINDOWS)) ? 1 : 0);
}
/* ToDo: pin down elapsed times to just the OS thread(s) that if (is_win9x) {
are evaluating/managing Haskell code. /* On Win9x, just attribute all running time to the user. */
*/ SYSTEMTIME st;
if (!GetProcessTimes (GetCurrentProcess(), &creationTime,
GetSystemTime(&st);
SystemTimeToFileTime(&st,&userTime);
} else {
/* ToDo: pin down elapsed times to just the OS thread(s) that
are evaluating/managing Haskell code.
*/
if (!GetProcessTimes (GetCurrentProcess(), &creationTime,
&exitTime, &kernelTime, &userTime)) { &exitTime, &kernelTime, &userTime)) {
/* Probably on a Win95 box..*/ /* Probably on a Win95 box..*/
CurrentElapsedTime = 0; CurrentElapsedTime = 0;
CurrentUserTime = 0; CurrentUserTime = 0;
return; return;
}
} }
FT2longlong(kT,kernelTime); FT2longlong(kT,kernelTime);
FT2longlong(uT,userTime); FT2longlong(uT,userTime);
CurrentElapsedTime = uT + kT; CurrentElapsedTime = uT + kT;
CurrentUserTime = uT; CurrentUserTime = uT;
if (is_win9x) {
/* Adjust for the fact that we're using system time & not
process time on Win9x. */
CurrentUserTime -= ElapsedTimeStart;
CurrentElapsedTime -= ElapsedTimeStart;
}
} }
#else /* !win32 */ #else /* !win32 */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment