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/lib/bb/utils.py | |
parent | 469bf3c58ebf153ad1829af7cf29e41e479af1d1 (diff) | |
download | 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/lib/bb/utils.py')
-rw-r--r-- | bitbake/lib/bb/utils.py | 20 |
1 files changed, 20 insertions, 0 deletions
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(): | |||
820 | def nonblockingfd(fd): | 820 | def 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 | ||
823 | def 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 | |||