1 /* -----------------------------------------------------------------------------
2 * $Id: Proftimer.c,v 1.12 2003/02/22 04:51:52 sof Exp $
4 * (c) The GHC Team, 1998-1999
6 * Profiling interval timer
8 * ---------------------------------------------------------------------------*/
10 #if defined (PROFILING)
12 #include "PosixSource.h"
17 #include "Profiling.h"
19 #include "Proftimer.h"
22 static rtsBool do_prof_ticks = rtsFalse; // enable profiling ticks
23 static rtsBool do_heap_prof_ticks = rtsFalse; // enable heap profiling ticks
25 // Number of ticks until next heap census
26 static int ticks_to_heap_profile;
28 // Time for a heap profile on the next context switch
29 rtsBool performHeapProfile;
34 do_prof_ticks = rtsFalse;
38 startProfTimer( void )
40 do_prof_ticks = rtsTrue;
44 stopHeapProfTimer( void )
46 do_heap_prof_ticks = rtsFalse;
50 startHeapProfTimer( void )
52 if (RtsFlags.ProfFlags.doHeapProfile &&
53 RtsFlags.ProfFlags.profileIntervalTicks > 0) {
54 do_heap_prof_ticks = rtsTrue;
61 performHeapProfile = rtsFalse;
63 RtsFlags.ProfFlags.profileIntervalTicks =
64 RtsFlags.ProfFlags.profileInterval / TICK_MILLISECS;
66 ticks_to_heap_profile = RtsFlags.ProfFlags.profileIntervalTicks;
79 if (do_heap_prof_ticks) {
80 ticks_to_heap_profile--;
81 if (ticks_to_heap_profile <= 0) {
82 ticks_to_heap_profile = RtsFlags.ProfFlags.profileIntervalTicks;
83 performHeapProfile = rtsTrue;
88 #endif /* PROFILING */