| 25 | |
| 26 | |
| 27 | void profile_enter( OBJECT * rulename, profile_frame * frame ) |
| 28 | { |
| 29 | if ( DEBUG_PROFILE ) |
| 30 | { |
| 31 | clock_t start = clock(); |
| 32 | profile_info * p; |
| 33 | |
| 34 | if ( !profile_hash && rulename ) |
| 35 | profile_hash = hashinit( sizeof( profile_info ), "profile" ); |
| 36 | |
| 37 | if ( rulename ) |
| 38 | { |
| 39 | int found; |
| 40 | p = (profile_info *)hash_insert( profile_hash, rulename, &found ); |
| 41 | if ( !found ) |
| 42 | { |
| 43 | p->name = rulename; |
| 44 | p->cumulative = 0; |
| 45 | p->net = 0; |
| 46 | p->num_entries = 0; |
| 47 | p->stack_count = 0; |
| 48 | p->memory = 0; |
| 49 | } |
| 50 | } |
| 51 | else |
| 52 | { |
| 53 | p = &profile_other; |
| 54 | } |
| 55 | |
| 56 | ++p->num_entries; |
| 57 | ++p->stack_count; |
| 58 | |
| 59 | frame->info = p; |
| 60 | |
| 61 | frame->caller = profile_stack; |
| 62 | profile_stack = frame; |
| 63 | |
| 64 | frame->entry_time = clock(); |
| 65 | frame->overhead = 0; |
| 66 | frame->subrules = 0; |
| 67 | |
| 68 | /* caller pays for the time it takes to play with the hash table */ |
| 69 | if ( frame->caller ) |
| 70 | frame->caller->overhead += frame->entry_time - start; |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | |
| 75 | void profile_memory( long mem ) |
no test coverage detected