X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FStats.c;h=5d4f772396c4fad5720e640b678621d4b0caf4eb;hb=5cb4bb13a817c44cdc4369c7f82949d9490d69a0;hp=4b2699040e3e5ee11caebd79ac2edf9a8597f803;hpb=dbef766ce79e37a74468a07a93b15ba1f06fe8f8;p=ghc-hetmet.git diff --git a/ghc/rts/Stats.c b/ghc/rts/Stats.c index 4b26990..5d4f772 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.46 2002/08/19 16:02:26 simonmar Exp $ * * (c) The GHC Team, 1998-1999 * @@ -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); + } } }