* [PATCH] utils: Improve profile log processing
@ 2014-08-27 13:56 Richard Purdie
0 siblings, 0 replies; only message in thread
From: Richard Purdie @ 2014-08-27 13:56 UTC (permalink / raw)
To: bitbake-devel
This stream redirection of stdout is horrible. pstats takes a stream argument
so lets use that instead.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 7d37a74..670e592 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -862,21 +862,16 @@ 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 = pstats.Stats(fn, stream=pout)
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()
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2014-08-27 13:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-27 13:56 [PATCH] utils: Improve profile log processing Richard Purdie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox