[project @ 1998-12-02 13:17:09 by simonm]
[ghc-hetmet.git] / ghc / rts / Proftimer.c
1 /* -----------------------------------------------------------------------------
2  * $Id: Proftimer.c,v 1.2 1998/12/02 13:28:36 simonm Exp $
3  *
4  * (c) The GHC Team, 1998
5  *
6  * Profiling interval timer
7  *
8  * ---------------------------------------------------------------------------*/
9
10 /* Only have cost centres etc if PROFILING defined */
11
12 #if defined (PROFILING)
13
14 #include "Rts.h"
15 #include "ProfRts.h"
16 #include "Itimer.h"
17 #include "Proftimer.h"
18
19 lnat total_ticks = 0;
20
21 nat current_interval = 1;               /* Current interval number -- 
22                                            stored in AGE */
23
24 nat interval_ticks = DEFAULT_INTERVAL;  /* No of ticks in an interval */
25
26 nat previous_ticks = 0;                 /* ticks in previous intervals */
27 nat current_ticks = 0;                  /* ticks in current interval */
28
29 void
30 initProfTimer(nat ms)
31 {
32   if (initialize_virtual_timer(ms)) {
33     fflush(stdout);
34     fprintf(stderr, "Can't initialize virtual timer.\n");
35     stg_exit(EXIT_FAILURE);
36   }
37 };
38
39 void
40 stopProfTimer(void)
41 {                               /* Stops time profile */
42   if (time_profiling) {
43     initProfTimer(0);
44   }
45 };
46
47 void
48 startProfTimer(void)
49 {                               /* Starts time profile */
50   if (time_profiling) {
51     initProfTimer(TICK_MILLISECS);
52   }
53 };
54
55 void
56 handleProfTick(void)
57 {
58   CCS_TICK(CCCS);
59   total_ticks++;
60 };
61
62 #endif /* PROFILING */