X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FProftimer.c;h=dc36df9d71cb7569f21b9315379ae613c851580c;hb=776afe7766a4fe991dbb5a38595900ebd95d4d5a;hp=42766d3df0189277ecc2cd11999db78bded2dcc4;hpb=bc5c802181b513216bc88f0d1ec9574157ee05fe;p=ghc-hetmet.git diff --git a/ghc/rts/Proftimer.c b/ghc/rts/Proftimer.c index 42766d3..dc36df9 100644 --- a/ghc/rts/Proftimer.c +++ b/ghc/rts/Proftimer.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Proftimer.c,v 1.7 2001/08/14 13:40:09 sewardj Exp $ + * $Id: Proftimer.c,v 1.12 2003/02/22 04:51:52 sof Exp $ * * (c) The GHC Team, 1998-1999 * @@ -10,34 +10,79 @@ #if defined (PROFILING) #include "PosixSource.h" + +#include + #include "Rts.h" #include "Profiling.h" -#include "Itimer.h" +#include "Timer.h" #include "Proftimer.h" +#include "RtsFlags.h" + +static rtsBool do_prof_ticks = rtsFalse; // enable profiling ticks +static rtsBool do_heap_prof_ticks = rtsFalse; // enable heap profiling ticks + +// Number of ticks until next heap census +static int ticks_to_heap_profile; -rtsBool do_prof_ticks = rtsFalse; /* enable profiling ticks */ +// Time for a heap profile on the next context switch +rtsBool performHeapProfile; void -stopProfTimer(void) -{ /* Stops time profile */ - if (time_profiling) { - do_prof_ticks = rtsFalse; - } -}; +stopProfTimer( void ) +{ + do_prof_ticks = rtsFalse; +} + +void +startProfTimer( void ) +{ + do_prof_ticks = rtsTrue; +} + +void +stopHeapProfTimer( void ) +{ + do_heap_prof_ticks = rtsFalse; +} void -startProfTimer(void) -{ /* Starts time profile */ - if (time_profiling) { - do_prof_ticks = rtsTrue; +startHeapProfTimer( void ) +{ + if (RtsFlags.ProfFlags.doHeapProfile && + RtsFlags.ProfFlags.profileIntervalTicks > 0) { + do_heap_prof_ticks = rtsTrue; } -}; +} + +void +initProfTimer( void ) +{ + performHeapProfile = rtsFalse; + + RtsFlags.ProfFlags.profileIntervalTicks = + RtsFlags.ProfFlags.profileInterval / TICK_MILLISECS; + + ticks_to_heap_profile = RtsFlags.ProfFlags.profileIntervalTicks; + + startHeapProfTimer(); +} + void handleProfTick(void) { if (do_prof_ticks) { - CCS_TICK(CCCS); + CCCS->time_ticks++; + } + + if (do_heap_prof_ticks) { + ticks_to_heap_profile--; + if (ticks_to_heap_profile <= 0) { + ticks_to_heap_profile = RtsFlags.ProfFlags.profileIntervalTicks; + performHeapProfile = rtsTrue; + } } } + #endif /* PROFILING */