1 /* -----------------------------------------------------------------------------
3 * (c) The GHC Team, 1998-1999
5 * Profiling interval timer
7 * ---------------------------------------------------------------------------*/
9 #include "PosixSource.h"
12 #include "Profiling.h"
13 #include "Proftimer.h"
14 #include "Capability.h"
17 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
;
32 do_prof_ticks
= rtsFalse
;
37 startProfTimer( void )
40 do_prof_ticks
= rtsTrue
;
45 stopHeapProfTimer( void )
47 do_heap_prof_ticks
= rtsFalse
;
51 startHeapProfTimer( void )
53 if (RtsFlags
.ProfFlags
.doHeapProfile
&&
54 RtsFlags
.ProfFlags
.heapProfileIntervalTicks
> 0) {
55 do_heap_prof_ticks
= rtsTrue
;
62 performHeapProfile
= rtsFalse
;
64 ticks_to_heap_profile
= RtsFlags
.ProfFlags
.heapProfileIntervalTicks
;
78 for (n
=0; n
< n_capabilities
; n
++) {
79 capabilities
[n
]->r
.rCCCS
->time_ticks
++;
84 if (do_heap_prof_ticks
) {
85 ticks_to_heap_profile
--;
86 if (ticks_to_heap_profile
<= 0) {
87 ticks_to_heap_profile
= RtsFlags
.ProfFlags
.heapProfileIntervalTicks
;
88 performHeapProfile
= rtsTrue
;