File: debug.h

package info (click to toggle)
boost-jam 3.1.16-1
  • links: PTS
  • area: main
  • in suites: lenny, squeeze
  • size: 5,012 kB
  • ctags: 6,357
  • sloc: ansic: 40,068; sh: 9,084; cpp: 894; yacc: 456; asm: 353; makefile: 156
file content (53 lines) | stat: -rw-r--r-- 1,558 bytes parent folder | download | duplicates (6)
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
/*
    Copyright Rene Rivera 2005.
    Distributed under the Boost Software License, Version 1.0.
    (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BJAM_DEBUG_H
#define BJAM_DEBUG_H

# include "jam.h"
# include <time.h>

struct profile_info
{
    /* name of rule being called */
    char* name;
    /* cumulative time spent in rule */
    clock_t cumulative;
    /* time spent in rule proper */
    clock_t net;
    /* number of time rule was entered */
    unsigned long num_entries;
    /* number of the times this function is present in stack */
    unsigned long stack_count;
    /* bytes of memory allocated by the call */
    unsigned long memory;
};
typedef struct profile_info profile_info;

struct profile_frame
{
    /* permanent storage where data accumulates */
    profile_info* info;
    /* overhead for profiling in this call */
    clock_t overhead;
    /* time of last entry to rule */
    clock_t entry_time;
    /* stack frame of caller */
    struct profile_frame* caller;
    /* time spent in subrules */
    clock_t subrules;
};
typedef struct profile_frame profile_frame;

profile_frame * profile_init( char* rulename, profile_frame* frame );
void profile_enter( char* rulename, profile_frame* frame );
void profile_memory( long mem );
void profile_exit(profile_frame* frame);
void profile_dump();

#define PROFILE_ENTER(scope) profile_frame PROF_ ## scope, *PROF_ ## scope ## _p = profile_init(#scope,&PROF_ ## scope)
#define PROFILE_EXIT(scope) profile_exit(PROF_ ## scope ## _p)

#endif