X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FProftimer.c;h=3b499152d66b768e682ec7b8947e07b5d6438720;hb=28a464a75e14cece5db40f2765a29348273ff2d2;hp=ad5bbd92072c7235f9b955d5c0784e1a71ab4e5f;hpb=c6ab4bfa09886be3bfff4aa747af2f1c8e348a1f;p=ghc-hetmet.git diff --git a/ghc/rts/Proftimer.c b/ghc/rts/Proftimer.c index ad5bbd9..3b49915 100644 --- a/ghc/rts/Proftimer.c +++ b/ghc/rts/Proftimer.c @@ -1,5 +1,4 @@ /* ----------------------------------------------------------------------------- - * $Id: Proftimer.c,v 1.5 1999/08/25 16:11:49 simonmar Exp $ * * (c) The GHC Team, 1998-1999 * @@ -7,37 +6,80 @@ * * ---------------------------------------------------------------------------*/ -/* Only have cost centres etc if PROFILING defined */ - #if defined (PROFILING) +#include "PosixSource.h" + #include "Rts.h" -#include "ProfRts.h" -#include "Itimer.h" +#include "Profiling.h" +#include "Timer.h" #include "Proftimer.h" +#include "RtsFlags.h" -nat current_interval = 1; /* Current interval number -- - stored in AGE */ +static rtsBool do_prof_ticks = rtsFalse; // enable profiling ticks +static rtsBool do_heap_prof_ticks = rtsFalse; // enable heap profiling ticks -nat interval_ticks = DEFAULT_INTERVAL; /* No of ticks in an interval */ +// Number of ticks until next heap census +static int ticks_to_heap_profile; -nat previous_ticks = 0; /* ticks in previous intervals */ -nat current_ticks = 0; /* ticks in current interval */ +// Time for a heap profile on the next context switch +rtsBool performHeapProfile; void -stopProfTimer(void) -{ /* Stops time profile */ - if (time_profiling) { +stopProfTimer( void ) +{ do_prof_ticks = rtsFalse; - } -}; +} void -startProfTimer(void) -{ /* Starts time profile */ - if (time_profiling) { +startProfTimer( void ) +{ do_prof_ticks = rtsTrue; - } -}; +} + +void +stopHeapProfTimer( void ) +{ + do_heap_prof_ticks = rtsFalse; +} + +void +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) { + 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 */