X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FProftimer.c;h=3b499152d66b768e682ec7b8947e07b5d6438720;hb=aa056e7fda12383c88de03c7b2ac611307d8019c;hp=077dc3f9f201463e41ac5bf78eca6dfe993014d8;hpb=7f309f1c021e7583f724cce599ce2dd3c439361b;p=ghc-hetmet.git diff --git a/ghc/rts/Proftimer.c b/ghc/rts/Proftimer.c index 077dc3f..3b49915 100644 --- a/ghc/rts/Proftimer.c +++ b/ghc/rts/Proftimer.c @@ -1,5 +1,4 @@ /* ----------------------------------------------------------------------------- - * $Id: Proftimer.c,v 1.3 1999/02/05 16:02:48 simonm Exp $ * * (c) The GHC Team, 1998-1999 * @@ -7,56 +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" -lnat total_ticks = 0; +static rtsBool do_prof_ticks = rtsFalse; // enable profiling ticks +static rtsBool do_heap_prof_ticks = rtsFalse; // enable heap profiling ticks -nat current_interval = 1; /* Current interval number -- - stored in AGE */ +// Number of ticks until next heap census +static int ticks_to_heap_profile; -nat interval_ticks = DEFAULT_INTERVAL; /* No of ticks in an interval */ +// Time for a heap profile on the next context switch +rtsBool performHeapProfile; -nat previous_ticks = 0; /* ticks in previous intervals */ -nat current_ticks = 0; /* ticks in current interval */ +void +stopProfTimer( void ) +{ + do_prof_ticks = rtsFalse; +} + +void +startProfTimer( void ) +{ + do_prof_ticks = rtsTrue; +} void -initProfTimer(nat ms) +stopHeapProfTimer( void ) { - if (initialize_virtual_timer(ms)) { - fflush(stdout); - fprintf(stderr, "Can't initialize virtual timer.\n"); - stg_exit(EXIT_FAILURE); - } -}; + do_heap_prof_ticks = rtsFalse; +} void -stopProfTimer(void) -{ /* Stops time profile */ - if (time_profiling) { - initProfTimer(0); - } -}; +startHeapProfTimer( void ) +{ + if (RtsFlags.ProfFlags.doHeapProfile && + RtsFlags.ProfFlags.profileIntervalTicks > 0) { + do_heap_prof_ticks = rtsTrue; + } +} void -startProfTimer(void) -{ /* Starts time profile */ - if (time_profiling) { - initProfTimer(TICK_MILLISECS); - } -}; +initProfTimer( void ) +{ + performHeapProfile = rtsFalse; + + RtsFlags.ProfFlags.profileIntervalTicks = + RtsFlags.ProfFlags.profileInterval / TICK_MILLISECS; + + ticks_to_heap_profile = RtsFlags.ProfFlags.profileIntervalTicks; + + startHeapProfTimer(); +} + void handleProfTick(void) { - CCS_TICK(CCCS); - total_ticks++; -}; + 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 */