diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-01-28 14:40:04 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-01-28 14:49:05 +0000 |
commit | dd335b09089c14016642a51b812500556e8f453c (patch) | |
tree | b2719a796d97a092b0329957cade909e7cd7082c /bitbake | |
parent | 469bf3c58ebf153ad1829af7cf29e41e479af1d1 (diff) | |
download | ast2050-yocto-poky-dd335b09089c14016642a51b812500556e8f453c.zip ast2050-yocto-poky-dd335b09089c14016642a51b812500556e8f453c.tar.gz |
bitbake: utils.py: Add function for processing profile output
(Bitbake rev: 0df64810e8d40e7761cfd5059c0617dda31a6641)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/cooker.py | 20 | ||||
-rw-r--r-- | bitbake/lib/bb/utils.py | 20 |
2 files changed, 21 insertions, 19 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index caf1123..80710fb 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py @@ -1416,25 +1416,7 @@ def server_main(cooker, func, *args): ret = profile.Profile.runcall(prof, func, *args) prof.dump_stats("profile.log") - - # Redirect stdout to capture profile information - pout = open('profile.log.processed', 'w') - so = sys.stdout.fileno() - orig_so = os.dup(sys.stdout.fileno()) - os.dup2(pout.fileno(), so) - - import pstats - p = pstats.Stats('profile.log') - p.sort_stats('time') - p.print_stats() - p.print_callers() - p.sort_stats('cumulative') - p.print_stats() - - os.dup2(orig_so, so) - pout.flush() - pout.close() - + bb.utils.process_profilelog("profile.log") print("Raw profiling information saved to profile.log and processed statistics to profile.log.processed") else: diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index cef0fdd..7e81df5 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py @@ -820,3 +820,23 @@ def cpu_count(): def nonblockingfd(fd): fcntl.fcntl(fd, fcntl.F_SETFL, fcntl.fcntl(fd, fcntl.F_GETFL) | os.O_NONBLOCK) +def process_profilelog(fn): + # Redirect stdout to capture profile information + pout = open(fn + '.processed', 'w') + so = sys.stdout.fileno() + orig_so = os.dup(sys.stdout.fileno()) + os.dup2(pout.fileno(), so) + + import pstats + p = pstats.Stats(fn) + p.sort_stats('time') + p.print_stats() + p.print_callers() + p.sort_stats('cumulative') + p.print_stats() + + os.dup2(orig_so, so) + pout.flush() + pout.close() + + |