From dd335b09089c14016642a51b812500556e8f453c Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Mon, 28 Jan 2013 14:40:04 +0000 Subject: bitbake: utils.py: Add function for processing profile output (Bitbake rev: 0df64810e8d40e7761cfd5059c0617dda31a6641) Signed-off-by: Richard Purdie --- bitbake/lib/bb/utils.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'bitbake/lib/bb/utils.py') 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(): 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() + + -- cgit v1.2.3-54-g00ecf