1 /* -----------------------------------------------------------------------------
3 * (c) The GHC Team, 1998-1999
5 * Profiling interval timer
7 * ---------------------------------------------------------------------------*/
9 #if defined (PROFILING)
11 #include "PosixSource.h"
14 #include "Profiling.h"
16 #include "Proftimer.h"
19 static rtsBool do_prof_ticks = rtsFalse; // enable profiling ticks
20 static rtsBool do_heap_prof_ticks = rtsFalse; // enable heap profiling ticks
22 // Number of ticks until next heap census
23 static int ticks_to_heap_profile;
25 // Time for a heap profile on the next context switch
26 rtsBool performHeapProfile;
31 do_prof_ticks = rtsFalse;
35 startProfTimer( void )
37 do_prof_ticks = rtsTrue;
41 stopHeapProfTimer( void )
43 do_heap_prof_ticks = rtsFalse;
47 startHeapProfTimer( void )
49 if (RtsFlags.ProfFlags.doHeapProfile &&
50 RtsFlags.ProfFlags.profileIntervalTicks > 0) {
51 do_heap_prof_ticks = rtsTrue;
58 performHeapProfile = rtsFalse;
60 RtsFlags.ProfFlags.profileIntervalTicks =
61 RtsFlags.ProfFlags.profileInterval / TICK_MILLISECS;
63 ticks_to_heap_profile = RtsFlags.ProfFlags.profileIntervalTicks;
76 if (do_heap_prof_ticks) {
77 ticks_to_heap_profile--;
78 if (ticks_to_heap_profile <= 0) {
79 ticks_to_heap_profile = RtsFlags.ProfFlags.profileIntervalTicks;
80 performHeapProfile = rtsTrue;
85 #endif /* PROFILING */