1 /* -----------------------------------------------------------------------------
2 * $Id: Proftimer.c,v 1.13 2004/09/03 15:28:37 simonmar Exp $
4 * (c) The GHC Team, 1998-1999
6 * Profiling interval timer
8 * ---------------------------------------------------------------------------*/
10 #if defined (PROFILING)
12 #include "PosixSource.h"
15 #include "Profiling.h"
17 #include "Proftimer.h"
20 static rtsBool do_prof_ticks = rtsFalse; // enable profiling ticks
21 static rtsBool do_heap_prof_ticks = rtsFalse; // enable heap profiling ticks
23 // Number of ticks until next heap census
24 static int ticks_to_heap_profile;
26 // Time for a heap profile on the next context switch
27 rtsBool performHeapProfile;
32 do_prof_ticks = rtsFalse;
36 startProfTimer( void )
38 do_prof_ticks = rtsTrue;
42 stopHeapProfTimer( void )
44 do_heap_prof_ticks = rtsFalse;
48 startHeapProfTimer( void )
50 if (RtsFlags.ProfFlags.doHeapProfile &&
51 RtsFlags.ProfFlags.profileIntervalTicks > 0) {
52 do_heap_prof_ticks = rtsTrue;
59 performHeapProfile = rtsFalse;
61 RtsFlags.ProfFlags.profileIntervalTicks =
62 RtsFlags.ProfFlags.profileInterval / TICK_MILLISECS;
64 ticks_to_heap_profile = RtsFlags.ProfFlags.profileIntervalTicks;
77 if (do_heap_prof_ticks) {
78 ticks_to_heap_profile--;
79 if (ticks_to_heap_profile <= 0) {
80 ticks_to_heap_profile = RtsFlags.ProfFlags.profileIntervalTicks;
81 performHeapProfile = rtsTrue;
86 #endif /* PROFILING */