generated from detiuaveiro/image8bit-pub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
instrumentation.h
54 lines (42 loc) · 1.36 KB
/
instrumentation.h
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
/// A generic instrumentation module.
///
/// João Manuel Rodrigues, AED, 2023
/// Code for cpu_time() by
/// Tomás Oliveira e Silva, AED, October 2021
///
/// Use as follows:
///
/// // Name the counters you're going to use:
/// InstrName[0] = "memops";
/// InstrName[1] = "adds";
/// InstrCalibrate(); // Call once, to measure CTU
/// ...
/// InstrReset(); // reset to zero
/// for (...) {
/// InstrCount[0] += 3; // to count array acesses
/// InstrCount[1] += 1; // to count addition
/// a[k] = a[i] + a[j];
/// }
/// InstrPrint(); // to show time and counters
#ifndef INSTRUMENTATION_H
#define INSTRUMENTATION_H
/// Cpu time in seconds
double cpu_time(void) ; ///
/// Ten counters should be more than enough
#define NUMCOUNTERS 10
/// Array of operation counters:
extern unsigned long InstrCount[NUMCOUNTERS]; ///extern
/// Array of names for the counters:
extern char* InstrName[NUMCOUNTERS]; ///extern
/// Cpu_time read on previous reset (~seconds)
extern double InstrTime; ///extern
/// Calibrated Time Unit (in seconds, initially 1s)
extern double InstrCTU; ///extern
/// Find the Calibrated Time Unit (CTU).
/// Run and time a loop of basic memory and arithmetic operations to set
/// a reasonably cpu-independent time unit.
void InstrCalibrate(void) ;
/// Reset counters to zero and store cpu_time.
void InstrReset(void) ;
void InstrPrint(void) ;
#endif