-
Notifications
You must be signed in to change notification settings - Fork 1
/
ccpal_example.c
72 lines (49 loc) · 1.46 KB
/
ccpal_example.c
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
63
64
65
66
67
68
69
70
/*
CCPal Example Code
Author: Paolo Fabio Zaino
Description:
This simple little program shows you how to use CCPal.
How this works is pretty simple, if you define the MACRO
MONITOR_PERFORMANCE
then this exmaple code will include the ccpal.h library
and will display performance monitor analysis per each
sections of your code where you called ccpal library,
while if you undef MONITOR_PERFORMANCE it will include
the empty header, so your code will be compiled without
ccpal extra code.
This program is distributed under GPLv2 license
*/
#include <stdio.h>
#define CCPAL_MONITOR_PERFORMANCE 1
#ifdef CCPAL_MONITOR_PERFORMANCE
#include "ccpal.h"
#else
#include "ccpal-empty.h"
#endif
void my_function_to_measure(char *text_par) {
fprintf (stdout, "%s", text_par);
}
int main() {
char *the_usual_test = "Hello World!\n\n";
/*
Here all the stuff related to Performance analysis:
*/
/*
This macro should be called before doing any measuring
it needs to be called only once at the beginning of your
principal function.
*/
CCPAL_INIT_LIB
/*
The MACRO below should be called just before the code
section you want to measure performance for
*/
CCPAL_START_MEASURING
/* Now let's execute the code we want to measure: */
my_function_to_measure( the_usual_test );
/* Ok, we are done, now let's stop measuring: */
CCPAL_STOP_MEASURING
/* Last step, let print out the mesurement: */
CCPAL_REPORT_ANALYSIS
return 0;
}