Propagate function time ratio allong the function calls. Must be called after finding the cycles. See also: - http://citeseer.ist.psu.edu/graham82gprof.html
(self, outevent, inevent)
| 357 | call.ratio = ratio(call[event], total) |
| 358 | |
| 359 | def integrate(self, outevent, inevent): |
| 360 | """Propagate function time ratio allong the function calls. |
| 361 | |
| 362 | Must be called after finding the cycles. |
| 363 | |
| 364 | See also: |
| 365 | - http://citeseer.ist.psu.edu/graham82gprof.html |
| 366 | """ |
| 367 | |
| 368 | # Sanity checking |
| 369 | assert outevent not in self |
| 370 | for function in self.functions.values(): |
| 371 | assert outevent not in function |
| 372 | assert inevent in function |
| 373 | for call in function.calls.values(): |
| 374 | assert outevent not in call |
| 375 | if call.callee_id != function.id: |
| 376 | assert call.ratio is not None |
| 377 | |
| 378 | # Aggregate the input for each cycle |
| 379 | for cycle in self.cycles: |
| 380 | total = inevent.null() |
| 381 | for function in self.functions.values(): |
| 382 | total = inevent.aggregate(total, function[inevent]) |
| 383 | self[inevent] = total |
| 384 | |
| 385 | # Integrate along the edges |
| 386 | total = inevent.null() |
| 387 | for function in self.functions.values(): |
| 388 | total = inevent.aggregate(total, function[inevent]) |
| 389 | self._integrate_function(function, outevent, inevent) |
| 390 | self[outevent] = total |
| 391 | |
| 392 | def _integrate_function(self, function, outevent, inevent): |
| 393 | if function.cycle is not None: |