1 /* -----------------------------------------------------------------------------
2 * $Id: Proftimer.c,v 1.9 2001/12/12 14:31:43 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 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 */