X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FStats.c;h=4920b4b88f0cd50f430b475f945be6dbbd88c229;hb=423d477bfecd490de1449c59325c8776f91d7aac;hp=4b2699040e3e5ee11caebd79ac2edf9a8597f803;hpb=dbef766ce79e37a74468a07a93b15ba1f06fe8f8;p=ghc-hetmet.git diff --git a/ghc/rts/Stats.c b/ghc/rts/Stats.c index 4b26990..4920b4b 100644 --- a/ghc/rts/Stats.c +++ b/ghc/rts/Stats.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Stats.c,v 1.39 2001/11/26 16:54:22 simonmar Exp $ + * $Id: Stats.c,v 1.48 2004/08/13 13:10:45 simonmar Exp $ * * (c) The GHC Team, 1998-1999 * @@ -14,12 +14,12 @@ #include "Rts.h" #include "RtsFlags.h" #include "RtsUtils.h" -#include "StoragePriv.h" #include "MBlock.h" #include "Schedule.h" #include "Stats.h" #include "ParTicky.h" /* ToDo: move into Rts.h */ #include "Profiling.h" +#include "Storage.h" #ifdef HAVE_UNISTD_H #include @@ -106,14 +106,14 @@ static TICK_TYPE HCe_start_time, HCe_tot_time = 0; // heap census prof elap ti #endif #ifdef PROFILING -#define PROF_VAL(x) x +#define PROF_VAL(x) (x) #else #define PROF_VAL(x) 0 #endif -lnat MaxResidency = 0; /* in words; for stats only */ -lnat AvgResidency = 0; -lnat ResidencySamples = 0; /* for stats only */ +static lnat MaxResidency = 0; // in words; for stats only +static lnat AvgResidency = 0; +static lnat ResidencySamples = 0; // for stats only static lnat GC_start_faults = 0, GC_end_faults = 0; @@ -354,9 +354,10 @@ stat_startExit(void) { getTimes(); MutElapsedStamp = CurrentElapsedTime; - MutElapsedTime = CurrentElapsedTime - GCe_tot_time - InitElapsedStamp; + MutElapsedTime = CurrentElapsedTime - GCe_tot_time - + PROF_VAL(RPe_tot_time + HCe_tot_time) - InitElapsedStamp; if (MutElapsedTime < 0) { MutElapsedTime = 0; } /* sometimes -0.00 */ - + /* for SMP, we don't know the mutator time yet, we have to inspect * all the running threads to find out, and they haven't stopped * yet. So we just timestamp MutUserTime at this point so we can @@ -578,17 +579,19 @@ stat_endHeapCensus(void) stats for this thread into the task_ids struct for that thread. -------------------------------------------------------------------------- */ -#ifdef SMP +#if defined(SMP) void stat_workerStop(void) { nat i; pthread_t me = pthread_self(); + getTimes(); + for (i = 0; i < RtsFlags.ParFlags.nNodes; i++) { if (task_ids[i].id == me) { - task_ids[i].mut_time = usertime() - task_ids[i].gc_time; - task_ids[i].mut_etime = elapsedtime() + task_ids[i].mut_time = CurrentUserTime - task_ids[i].gc_time; + task_ids[i].mut_etime = CurrentElapsedTime - GCe_tot_time - task_ids[i].elapsedtimestart; if (task_ids[i].mut_time < 0.0) { task_ids[i].mut_time = 0.0; } @@ -598,6 +601,14 @@ stat_workerStop(void) } #endif +#if defined(SMP) +long int stat_getElapsedTime () +{ + getTimes(); + return CurrentElapsedTime; +} +#endif + /* ----------------------------------------------------------------------------- Called at the end of execution @@ -738,7 +749,8 @@ stat_exit(int alloc) fprintf(sf, "<>\n", total_collections, - AvgResidency*sizeof(W_)/ResidencySamples, + ResidencySamples == 0 ? 0 : + AvgResidency*sizeof(W_)/ResidencySamples, MaxResidency*sizeof(W_), ResidencySamples, (unsigned long)(mblocks_allocated * MBLOCK_SIZE / (1024L * 1024L)), @@ -748,7 +760,9 @@ stat_exit(int alloc) } fflush(sf); - fclose(sf); + if (sf != stderr) { + fclose(sf); + } } } @@ -807,5 +821,5 @@ statDescribeGens(void) each compilation and expression evaluation. -------------------------------------------------------------------------- */ -extern HsInt getAllocations( void ) -{ return (HsInt)(total_allocated * sizeof(W_)); } +extern HsInt64 getAllocations( void ) +{ return (HsInt64)total_allocated * sizeof(W_); }