modules/ims_qos: added patch for flow-description bug when request originates from...
[sip-router] / lib / cds / simple_profile.h
1 #ifndef __SIMPLE_PROFILE_H
2 #define __SIMPLE_PROFILE_H
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7         
8 typedef void(*trace_f)();
9
10 int start_profile(trace_f tf);
11 int stop_profile();
12
13 /* do NOT use this directly ! */
14 extern unsigned int tick_counter;
15
16 #define get_prof_time() tick_counter
17
18 typedef struct {
19         int count;
20         int start_count, stop_count;
21         unsigned int spent_time;
22 } profile_data_t;
23
24 #define DEFINE_PROF_POINT(name) profile_data_t prof_##name = { 0, 0, 0 };
25 #define DECLARE_PROF_POINT(name) extern profile_data_t prof_##name;
26
27 #define prof_point(name)        prof_##name
28 #define PROF_START_DECL(name)   int _prof_act_##name;
29 #define PROF_START_BODY(name)   prof_point(name).count++; \
30                                                         prof_point(name).start_count++; \
31                                                         _prof_act_##name = get_prof_time();
32
33 #define PROF_START(name)        int _prof_act_##name; \
34                                                         prof_point(name).count++; \
35                                                         prof_point(name).start_count++; \
36                                                         _prof_act_##name = get_prof_time();
37
38 #define PROF_STOP(name) prof_point(name).stop_count++; \
39                                                 prof_point(name).spent_time += get_prof_time() - _prof_act_##name;
40
41 #define prof_return(a, val)     prof_stop(a) return val;
42
43 #ifdef __cplusplus
44 }
45 #endif
46  
47 #endif