1 /* -----------------------------------------------------------------------------
2 * $Id: Proftimer.c,v 1.8 2001/11/22 14:25:12 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;
33 do_prof_ticks = rtsFalse;
38 startProfTimer( void )
41 do_prof_ticks = rtsTrue;
46 stopHeapProfTimer( void )
48 do_heap_prof_ticks = rtsFalse;
52 startHeapProfTimer( void )
54 if (RtsFlags.ProfFlags.doHeapProfile) {
55 do_heap_prof_ticks = rtsTrue;
62 performHeapProfile = rtsFalse;
64 RtsFlags.ProfFlags.profileIntervalTicks =
65 RtsFlags.ProfFlags.profileInterval / TICK_MILLISECS;
67 ticks_to_heap_profile = RtsFlags.ProfFlags.profileIntervalTicks;
80 if (do_heap_prof_ticks) {
81 ticks_to_heap_profile--;
82 if (ticks_to_heap_profile <= 0) {
83 ticks_to_heap_profile = RtsFlags.ProfFlags.profileIntervalTicks;
84 performHeapProfile = rtsTrue;
89 #endif /* PROFILING */