diff options
| -rw-r--r-- | bitbake/lib/bb/cooker.py | 6 | ||||
| -rw-r--r-- | bitbake/lib/bb/utils.py | 34 |
2 files changed, 27 insertions, 13 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index fe33a4f34c..0ad79bd53e 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py | |||
| @@ -2241,9 +2241,9 @@ class CookerParser(object): | |||
| 2241 | profiles.append(logfile) | 2241 | profiles.append(logfile) |
| 2242 | 2242 | ||
| 2243 | if profiles: | 2243 | if profiles: |
| 2244 | pout = "profile-parse.log.processed" | 2244 | fn_out = "profile-parse.log.report" |
| 2245 | bb.utils.process_profilelog(profiles, pout = pout) | 2245 | bb.utils.process_profilelog(profiles, fn_out=fn_out) |
| 2246 | print("Processed parsing statistics saved to %s" % (pout)) | 2246 | print("Processed parsing statistics saved to %s" % (fn_out)) |
| 2247 | 2247 | ||
| 2248 | def final_cleanup(self): | 2248 | def final_cleanup(self): |
| 2249 | if self.syncthread: | 2249 | if self.syncthread: |
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index 016036dbce..c288c826c0 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
| @@ -1441,29 +1441,43 @@ def profile_function(profile, function, output_fn, process=True): | |||
| 1441 | prof.dump_stats(output_fn) | 1441 | prof.dump_stats(output_fn) |
| 1442 | if process: | 1442 | if process: |
| 1443 | process_profilelog(output_fn) | 1443 | process_profilelog(output_fn) |
| 1444 | serverlog("Raw profiling information saved to %s and processed statistics to %s.processed" % (output_fn, output_fn)) | 1444 | serverlog("Raw profiling information saved to %s and processed statistics to %s.report*" % (output_fn, output_fn)) |
| 1445 | return ret | 1445 | return ret |
| 1446 | else: | 1446 | else: |
| 1447 | return function() | 1447 | return function() |
| 1448 | 1448 | ||
| 1449 | def process_profilelog(fn, pout = None): | 1449 | def process_profilelog(fn, fn_out = None): |
| 1450 | # Either call with a list of filenames and set pout or a filename and optionally pout. | 1450 | # Either call with a list of filenames and set pout or a filename and optionally pout. |
| 1451 | if not pout: | 1451 | import pstats |
| 1452 | pout = fn + '.processed' | ||
| 1453 | 1452 | ||
| 1454 | with open(pout, 'w') as pout: | 1453 | if not fn_out: |
| 1455 | import pstats | 1454 | fn_out = fn + '.report' |
| 1455 | |||
| 1456 | def pstatopen(): | ||
| 1456 | if isinstance(fn, list): | 1457 | if isinstance(fn, list): |
| 1457 | p = pstats.Stats(*fn, stream=pout) | 1458 | return pstats.Stats(*fn, stream=pout) |
| 1458 | else: | 1459 | return pstats.Stats(fn, stream=pout) |
| 1459 | p = pstats.Stats(fn, stream=pout) | 1460 | |
| 1461 | with open(fn_out + '.time', 'w') as pout: | ||
| 1462 | p = pstatopen() | ||
| 1460 | p.sort_stats('time') | 1463 | p.sort_stats('time') |
| 1461 | p.print_stats() | 1464 | p.print_stats() |
| 1465 | |||
| 1466 | with open(fn_out + '.time-callers', 'w') as pout: | ||
| 1467 | p = pstatopen() | ||
| 1468 | p.sort_stats('time') | ||
| 1462 | p.print_callers() | 1469 | p.print_callers() |
| 1470 | |||
| 1471 | with open(fn_out + '.cumulative', 'w') as pout: | ||
| 1472 | p = pstatopen() | ||
| 1463 | p.sort_stats('cumulative') | 1473 | p.sort_stats('cumulative') |
| 1464 | p.print_stats() | 1474 | p.print_stats() |
| 1465 | 1475 | ||
| 1466 | pout.flush() | 1476 | with open(fn_out + '.cumulative-callers', 'w') as pout: |
| 1477 | p = pstatopen() | ||
| 1478 | p.sort_stats('cumulative') | ||
| 1479 | p.print_callers() | ||
| 1480 | |||
| 1467 | 1481 | ||
| 1468 | # | 1482 | # |
| 1469 | # Was present to work around multiprocessing pool bugs in python < 2.7.3 | 1483 | # Was present to work around multiprocessing pool bugs in python < 2.7.3 |
