summaryrefslogtreecommitdiff
path: root/ghc/rts/Proftimer.c
blob: bd50c98350132f02b1737f88698076c7d4138f41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* -----------------------------------------------------------------------------
 * $Id: Proftimer.c,v 1.2 1998/12/02 13:28:36 simonm Exp $
 *
 * (c) The GHC Team, 1998
 *
 * Profiling interval timer
 *
 * ---------------------------------------------------------------------------*/

/* Only have cost centres etc if PROFILING defined */

#if defined (PROFILING)

#include "Rts.h"
#include "ProfRts.h"
#include "Itimer.h"
#include "Proftimer.h"

lnat total_ticks = 0;

nat current_interval = 1;               /* Current interval number -- 
					   stored in AGE */

nat interval_ticks = DEFAULT_INTERVAL;  /* No of ticks in an interval */

nat previous_ticks = 0;                 /* ticks in previous intervals */
nat current_ticks = 0;                  /* ticks in current interval */

void
initProfTimer(nat ms)
{
  if (initialize_virtual_timer(ms)) {
    fflush(stdout);
    fprintf(stderr, "Can't initialize virtual timer.\n");
    stg_exit(EXIT_FAILURE);
  }
};

void
stopProfTimer(void)
{				/* Stops time profile */
  if (time_profiling) {
    initProfTimer(0);
  }
};

void
startProfTimer(void)
{				/* Starts time profile */
  if (time_profiling) {
    initProfTimer(TICK_MILLISECS);
  }
};

void
handleProfTick(void)
{
  CCS_TICK(CCCS);
  total_ticks++;
};

#endif /* PROFILING */