summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/bb/cooker.py20
-rw-r--r--bitbake/lib/bb/utils.py20
2 files changed, 21 insertions, 19 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index caf1123496..80710fb97d 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -1416,25 +1416,7 @@ def server_main(cooker, func, *args):
1416 ret = profile.Profile.runcall(prof, func, *args) 1416 ret = profile.Profile.runcall(prof, func, *args)
1417 1417
1418 prof.dump_stats("profile.log") 1418 prof.dump_stats("profile.log")
1419 1419 bb.utils.process_profilelog("profile.log")
1420 # Redirect stdout to capture profile information
1421 pout = open('profile.log.processed', 'w')
1422 so = sys.stdout.fileno()
1423 orig_so = os.dup(sys.stdout.fileno())
1424 os.dup2(pout.fileno(), so)
1425
1426 import pstats
1427 p = pstats.Stats('profile.log')
1428 p.sort_stats('time')
1429 p.print_stats()
1430 p.print_callers()
1431 p.sort_stats('cumulative')
1432 p.print_stats()
1433
1434 os.dup2(orig_so, so)
1435 pout.flush()
1436 pout.close()
1437
1438 print("Raw profiling information saved to profile.log and processed statistics to profile.log.processed") 1420 print("Raw profiling information saved to profile.log and processed statistics to profile.log.processed")
1439 1421
1440 else: 1422 else:
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index cef0fdd5b8..7e81df5855 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -820,3 +820,23 @@ def cpu_count():
820def nonblockingfd(fd): 820def nonblockingfd(fd):
821 fcntl.fcntl(fd, fcntl.F_SETFL, fcntl.fcntl(fd, fcntl.F_GETFL) | os.O_NONBLOCK) 821 fcntl.fcntl(fd, fcntl.F_SETFL, fcntl.fcntl(fd, fcntl.F_GETFL) | os.O_NONBLOCK)
822 822
823def process_profilelog(fn):
824 # Redirect stdout to capture profile information
825 pout = open(fn + '.processed', 'w')
826 so = sys.stdout.fileno()
827 orig_so = os.dup(sys.stdout.fileno())
828 os.dup2(pout.fileno(), so)
829
830 import pstats
831 p = pstats.Stats(fn)
832 p.sort_stats('time')
833 p.print_stats()
834 p.print_callers()
835 p.sort_stats('cumulative')
836 p.print_stats()
837
838 os.dup2(orig_so, so)
839 pout.flush()
840 pout.close()
841
842