summaryrefslogtreecommitdiffstats
path: root/lib/bb/cooker.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2013-09-15 08:57:02 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-09-17 14:09:37 +0100
commitf8a6e4caed4dc3dcf207aecc4ea5f438027da8be (patch)
treea218ec1dd568d33ad8fcedcee1c588b360b66803 /lib/bb/cooker.py
parent468c221449290c4f196e87f7d8e23fcd7db86135 (diff)
downloadbitbake-f8a6e4caed4dc3dcf207aecc4ea5f438027da8be.tar.gz
cooker: Allow profiling of the parser in profile mode
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/cooker.py')
-rw-r--r--lib/bb/cooker.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index 988f2cad0..a0e282b85 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -1467,7 +1467,7 @@ class Feeder(multiprocessing.Process):
continue
class Parser(multiprocessing.Process):
- def __init__(self, jobs, results, quit, init):
+ def __init__(self, jobs, results, quit, init, profile):
self.jobs = jobs
self.results = results
self.quit = quit
@@ -1475,8 +1475,28 @@ class Parser(multiprocessing.Process):
multiprocessing.Process.__init__(self)
self.context = bb.utils.get_context().copy()
self.handlers = bb.event.get_class_handlers().copy()
+ self.profile = profile
def run(self):
+
+ if not self.profile:
+ self.realrun()
+ return
+
+ try:
+ import cProfile as profile
+ except:
+ import profile
+ prof = profile.Profile()
+ try:
+ profile.Profile.runcall(prof, self.realrun)
+ finally:
+ logfile = "profile-parse-%s.log" % multiprocessing.current_process().name
+ prof.dump_stats(logfile)
+ bb.utils.process_profilelog(logfile)
+ print("Raw profiling information saved to %s and processed statistics to %s.processed" % (logfile, logfile))
+
+ def realrun(self):
if self.init:
self.init()
@@ -1577,7 +1597,7 @@ class CookerParser(object):
self.feeder = Feeder(self.willparse, self.jobs, self.feeder_quit)
self.feeder.start()
for i in range(0, self.num_processes):
- parser = Parser(self.jobs, self.result_queue, self.parser_quit, init)
+ parser = Parser(self.jobs, self.result_queue, self.parser_quit, init, self.cooker.configuration.profile)
parser.start()
self.processes.append(parser)