summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/utils.py')
-rw-r--r--bitbake/lib/bb/utils.py34
1 files changed, 24 insertions, 10 deletions
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
1449def process_profilelog(fn, pout = None): 1449def 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