-
Notifications
You must be signed in to change notification settings - Fork 0
/
profiling.h
57 lines (45 loc) · 978 Bytes
/
profiling.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
54
55
56
57
// Copied from http://www.dudley.nu/arduino_profiling/
#ifndef PROFILING_H
#if PROFILING
#ifndef MAXPROF
#define MAXPROF 30
#endif
#define PF(n) do{prof_line=n;}while(0)
#if PROFILING_MAIN
#define EXTERN
#else
#define EXTERN extern
#endif
EXTERN volatile unsigned long prof_array[MAXPROF];
EXTERN volatile unsigned int prof_line;
EXTERN volatile unsigned char prof_has_dumped;
#if PROFILING_MAIN
#define _DL(x) Serial.print(x)
#define _DLn(x) Serial.println(x)
void clear_profiling_data (void) {
unsigned char c;
for(c = 0 ; c < MAXPROF ; c++) {
prof_array[c] = 0;
}
}
void dump_profiling_data(void) {
unsigned char c;
prof_has_dumped = 1;
PF(0);
for(c = 0 ; c < MAXPROF ; c++) {
_DL((int)c);
_DL(" ");
_DLn((unsigned long)prof_array[c]);
prof_array[c] = 0;
}
}
inline void update_profiling_data(void) {
prof_array[prof_line]++;
}
#endif
#else
#define PF(n)
#define mydelay(v) delay(v)
#endif
#define PROFILING_H 1
#endif