[project @ 1999-08-04 17:03:20 by panne]
[ghc-hetmet.git] / ghc / rts / Proftimer.c
1 /* -----------------------------------------------------------------------------
2  * $Id: Proftimer.c,v 1.4 1999/08/04 17:03:41 panne Exp $
3  *
4  * (c) The GHC Team, 1998-1999
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 /* For a small collection of signal handler prototypes, see
56    http://web2.airmail.net/sjbaker1/software/signal_collection.html */
57
58 void
59 handleProfTick(int unused)
60 {
61   (void)unused;   /* no warnings, please */
62   CCS_TICK(CCCS);
63   total_ticks++;
64 };
65
66 #endif /* PROFILING */