1 | /* |
---|
2 | Copyright Rene Rivera 2005. |
---|
3 | Distributed under the Boost Software License, Version 1.0. |
---|
4 | (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) |
---|
5 | */ |
---|
6 | #ifndef BJAM_DEBUG_H |
---|
7 | #define BJAM_DEBUG_H |
---|
8 | |
---|
9 | # include "jam.h" |
---|
10 | # include <time.h> |
---|
11 | |
---|
12 | struct profile_info |
---|
13 | { |
---|
14 | /* name of rule being called */ |
---|
15 | char* name; |
---|
16 | /* cumulative time spent in rule */ |
---|
17 | clock_t cumulative; |
---|
18 | /* time spent in rule proper */ |
---|
19 | clock_t net; |
---|
20 | /* number of time rule was entered */ |
---|
21 | unsigned long num_entries; |
---|
22 | /* number of the times this function is present in stack */ |
---|
23 | unsigned long stack_count; |
---|
24 | /* bytes of memory allocated by the call */ |
---|
25 | unsigned long memory; |
---|
26 | }; |
---|
27 | typedef struct profile_info profile_info; |
---|
28 | |
---|
29 | struct profile_frame |
---|
30 | { |
---|
31 | /* permanent storage where data accumulates */ |
---|
32 | profile_info* info; |
---|
33 | /* overhead for profiling in this call */ |
---|
34 | clock_t overhead; |
---|
35 | /* time of last entry to rule */ |
---|
36 | clock_t entry_time; |
---|
37 | /* stack frame of caller */ |
---|
38 | struct profile_frame* caller; |
---|
39 | /* time spent in subrules */ |
---|
40 | clock_t subrules; |
---|
41 | }; |
---|
42 | typedef struct profile_frame profile_frame; |
---|
43 | |
---|
44 | profile_frame * profile_init( char* rulename, profile_frame* frame ); |
---|
45 | void profile_enter( char* rulename, profile_frame* frame ); |
---|
46 | void profile_memory( long mem ); |
---|
47 | void profile_exit(profile_frame* frame); |
---|
48 | void profile_dump(); |
---|
49 | |
---|
50 | #define PROFILE_ENTER(scope) profile_frame PROF_ ## scope, *PROF_ ## scope ## _p = profile_init(#scope,&PROF_ ## scope) |
---|
51 | #define PROFILE_EXIT(scope) profile_exit(PROF_ ## scope ## _p) |
---|
52 | |
---|
53 | #endif |
---|