diff options
author | Patrick Simianer <simianer@cl.uni-heidelberg.de> | 2012-05-13 03:35:30 +0200 |
---|---|---|
committer | Patrick Simianer <simianer@cl.uni-heidelberg.de> | 2012-05-13 03:35:30 +0200 |
commit | 670a8f984fc6d8342180c59ae9e96b0b76f34d3d (patch) | |
tree | 9f2ce7eec1a77e56b3bb1ad0ad40f212d7a996b0 /jam-files/engine/debug.h | |
parent | eb3ee28dc0eb1d3e5ed01ba0df843be329ae450d (diff) | |
parent | 2f64af3e06a518b93f7ca2c30a9d0aeb2c947031 (diff) |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'jam-files/engine/debug.h')
-rw-r--r-- | jam-files/engine/debug.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/jam-files/engine/debug.h b/jam-files/engine/debug.h new file mode 100644 index 00000000..115a8873 --- /dev/null +++ b/jam-files/engine/debug.h @@ -0,0 +1,54 @@ +/* + 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 |