X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FStats.c;h=3b1213554ccf94e73d950d173843e3b79b5d44bf;hb=f5c94708c39c7b64c0d52057408332ed837834e6;hp=53dd7fc5935006cf356d41c18971044bde762978;hpb=9874c5e7c747d92121ea61de3319cee628f3a80a;p=ghc-hetmet.git diff --git a/ghc/rts/Stats.c b/ghc/rts/Stats.c index 53dd7fc..3b12135 100644 --- a/ghc/rts/Stats.c +++ b/ghc/rts/Stats.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Stats.c,v 1.24 2001/03/14 15:01:04 sewardj Exp $ + * $Id: Stats.c,v 1.30 2001/07/08 17:04:04 sof Exp $ * * (c) The GHC Team, 1998-1999 * @@ -16,6 +16,7 @@ #include "MBlock.h" #include "Schedule.h" #include "Stats.h" +#include "ParTicky.h" // ToDo: move into Rts.h #ifdef HAVE_UNISTD_H #include @@ -55,6 +56,10 @@ #include #endif +#if defined(PAR) || !(!defined(HAVE_GETRUSAGE) || irix_TARGET_OS || defined(mingw32_TARGET_OS) || defined(cygwin32_TARGET_OS)) +#include +#endif + /* huh? */ #define BIG_STRING_LEN 512 @@ -102,17 +107,17 @@ static nat pageFaults(void); /* elapsedtime() -- The current elapsed time in seconds */ -#ifdef _WIN32 -#define NS_PER_SEC 10000000LL -/* Convert FILETIMEs into secs since the Epoch (Jan1-1970) */ +#if defined(mingw32_TARGET_OS) || defined(cygwin32_TARGET_OS) +#define HNS_PER_SEC 10000000LL /* FILETIMES are in units of 100ns */ +/* Convert FILETIMEs into secs */ #define FT2longlong(ll,ft) \ (ll)=(ft).dwHighDateTime; \ (ll) <<= 32; \ (ll) |= (ft).dwLowDateTime; \ - (ll) /= (unsigned long long) (NS_PER_SEC / CLOCKS_PER_SEC) + (ll) /= (unsigned long long) (HNS_PER_SEC / CLOCKS_PER_SEC) #endif -#ifdef _WIN32 +#if defined(mingw32_TARGET_OS) || defined(cygwin32_TARGET_OS) /* cygwin32 or mingw32 version */ static void getTimes(void) @@ -126,7 +131,9 @@ getTimes(void) if (!GetProcessTimes (GetCurrentProcess(), &creationTime, &exitTime, &kernelTime, &userTime)) { /* Probably on a Win95 box..*/ - return 0; + CurrentElapsedTime = 0; + CurrentUserTime = 0; + return; } FT2longlong(kT,kernelTime); @@ -135,20 +142,20 @@ getTimes(void) CurrentUserTime = uT; } -#else /* !_WIN32 */ +#else /* !win32 */ static void getTimes(void) { -# if !defined(HAVE_TIMES) +#ifndef HAVE_TIMES /* We will #ifdef around the fprintf for machines we *know* are unsupported. (WDP 94/05) */ fprintf(stderr, "NOTE: `getTimes' does nothing!\n"); return 0.0; -# else /* not stumped */ +#else /* not stumped */ struct tms t; clock_t r = times(&t); @@ -157,7 +164,7 @@ getTimes(void) #endif } -#endif /* !_WIN32 */ +#endif /* !win32 */ /* mut_user_time_during_GC() and mut_user_time() * @@ -189,7 +196,7 @@ pageFaults(void) { /* ToDo (on NT): better, get this via the performance data that's stored in the registry. */ -# if !defined(HAVE_GETRUSAGE) || irix_TARGET_OS || defined(_WIN32) +# if !defined(HAVE_GETRUSAGE) || irix_TARGET_OS || defined(mingw32_TARGET_OS) || defined(cygwin32_TARGET_OS) return 0; # else struct rusage t; @@ -237,20 +244,21 @@ stat_startInit(void) fprintf(stderr, "stat_init: bad call to 'sysconf'!\n"); stg_exit(EXIT_FAILURE); } - TicksPerSecond = (double) ticks; + TicksPerSecond = ticks; /* no "sysconf" or CLK_TCK; had better guess */ #elif defined(HZ) - TicksPerSecond = (StgDouble) (HZ); + TicksPerSecond = HZ; #elif defined(CLOCKS_PER_SEC) - TicksPerSecond = (StgDouble) (CLOCKS_PER_SEC); + TicksPerSecond = CLOCKS_PER_SEC; + #else /* had better guess wildly */ /* We will #ifdef around the fprintf for machines we *know* are unsupported. (WDP 94/05) */ fprintf(stderr, "NOTE: Guessing `TicksPerSecond = 60'!\n"); - TicksPerSecond = 60.0; + TicksPerSecond = 60; #endif getTimes(); @@ -585,12 +593,14 @@ stat_exit(int alloc) } if (RtsFlags.GcFlags.giveStats == ONELINE_GC_STATS && sf != NULL) { - fprintf(sf, "<>\n", - GC_tot_alloc*sizeof(W_), total_collections, + /* print the long long separately to avoid bugginess on mingwin (2001-07-02, mingw-0.5) */ + fprintf(sf, "<>\n", + total_collections, AvgResidency*sizeof(W_)/ResidencySamples, MaxResidency*sizeof(W_), - ResidencySamples, - mblocks_allocated * MBLOCK_SIZE / (1024 * 1024), + ResidencySamples, + (unsigned long)(mblocks_allocated * MBLOCK_SIZE / (1024L * 1024L)), TICK_TO_DBL(InitUserTime), TICK_TO_DBL(InitElapsedTime), TICK_TO_DBL(MutUserTime), TICK_TO_DBL(MutElapsedTime), TICK_TO_DBL(GC_tot_time), TICK_TO_DBL(GCe_tot_time));