| 78 | } |
| 79 | |
| 80 | PerformanceInfo* RuntimeStatistics::computeDifference(Attachment* att, |
| 81 | const RuntimeStatistics& new_stat, |
| 82 | PerformanceInfo& dest, |
| 83 | TraceCountsArray& temp) |
| 84 | { |
| 85 | // NOTE: we do not initialize dest.pin_time. This must be done by the caller |
| 86 | |
| 87 | // Calculate database-level statistics |
| 88 | for (int i = 0; i < TOTAL_ITEMS; i++) |
| 89 | values[i] = new_stat.values[i] - values[i]; |
| 90 | |
| 91 | dest.pin_counters = values; |
| 92 | |
| 93 | // Calculate relation-level statistics |
| 94 | temp.clear(); |
| 95 | |
| 96 | // This loop assumes that base array is smaller than new one |
| 97 | RelCounters::iterator base_cnts = rel_counts.begin(); |
| 98 | bool base_found = (base_cnts != rel_counts.end()); |
| 99 | |
| 100 | RelCounters::const_iterator new_cnts = new_stat.rel_counts.begin(); |
| 101 | const RelCounters::const_iterator end = new_stat.rel_counts.end(); |
| 102 | for (; new_cnts != end; ++new_cnts) |
| 103 | { |
| 104 | const SLONG rel_id = new_cnts->getRelationId(); |
| 105 | |
| 106 | if (base_found && base_cnts->getRelationId() == rel_id) |
| 107 | { |
| 108 | // Point TraceCounts to counts array from baseline object |
| 109 | if (base_cnts->setToDiff(*new_cnts)) |
| 110 | { |
| 111 | jrd_rel* const relation = |
| 112 | rel_id < static_cast<SLONG>(att->att_relations->count()) ? |
| 113 | (*att->att_relations)[rel_id] : NULL; |
| 114 | |
| 115 | TraceCounts traceCounts; |
| 116 | traceCounts.trc_relation_id = rel_id; |
| 117 | traceCounts.trc_counters = base_cnts->getCounterVector(); |
| 118 | traceCounts.trc_relation_name = relation ? relation->rel_name.c_str() : NULL; |
| 119 | temp.add(traceCounts); |
| 120 | } |
| 121 | |
| 122 | ++base_cnts; |
| 123 | base_found = (base_cnts != rel_counts.end()); |
| 124 | } |
| 125 | else |
| 126 | { |
| 127 | jrd_rel* const relation = |
| 128 | rel_id < static_cast<SLONG>(att->att_relations->count()) ? |
| 129 | (*att->att_relations)[rel_id] : NULL; |
| 130 | |
| 131 | // Point TraceCounts to counts array from object with updated counters |
| 132 | TraceCounts traceCounts; |
| 133 | traceCounts.trc_relation_id = rel_id; |
| 134 | traceCounts.trc_counters = new_cnts->getCounterVector(); |
| 135 | traceCounts.trc_relation_name = relation ? relation->rel_name.c_str() : NULL; |
| 136 | temp.add(traceCounts); |
| 137 | } |
no test coverage detected