summaryrefslogtreecommitdiffstats
path: root/bitbake
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:11:03 +0100
commit602bb695cfa4b90f3c35800ffacbf50e71db4cd0 (patch)
treecf738d42d59b30fcffdd62af823f2c3865eee6c0 /bitbake
parenteb4854f903e31706d2d395d05521424bfa303c0d (diff)
downloadpoky-602bb695cfa4b90f3c35800ffacbf50e71db4cd0.tar.gz
bitbake: cooker: Allow profiling of the parser in profile mode
(Bitbake rev: f8a6e4caed4dc3dcf207aecc4ea5f438027da8be) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/cooker.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 988f2cad07..a0e282b854 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -1467,7 +1467,7 @@ class Feeder(multiprocessing.Process):
1467 continue 1467 continue
1468 1468
1469class Parser(multiprocessing.Process): 1469class Parser(multiprocessing.Process):
1470 def __init__(self, jobs, results, quit, init): 1470 def __init__(self, jobs, results, quit, init, profile):
1471 self.jobs = jobs 1471 self.jobs = jobs
1472 self.results = results 1472 self.results = results
1473 self.quit = quit 1473 self.quit = quit
@@ -1475,8 +1475,28 @@ class Parser(multiprocessing.Process):
1475 multiprocessing.Process.__init__(self) 1475 multiprocessing.Process.__init__(self)
1476 self.context = bb.utils.get_context().copy() 1476 self.context = bb.utils.get_context().copy()
1477 self.handlers = bb.event.get_class_handlers().copy() 1477 self.handlers = bb.event.get_class_handlers().copy()
1478 self.profile = profile
1478 1479
1479 def run(self): 1480 def run(self):
1481
1482 if not self.profile:
1483 self.realrun()
1484 return
1485
1486 try:
1487 import cProfile as profile
1488 except:
1489 import profile
1490 prof = profile.Profile()
1491 try:
1492 profile.Profile.runcall(prof, self.realrun)
1493 finally:
1494 logfile = "profile-parse-%s.log" % multiprocessing.current_process().name
1495 prof.dump_stats(logfile)
1496 bb.utils.process_profilelog(logfile)
1497 print("Raw profiling information saved to %s and processed statistics to %s.processed" % (logfile, logfile))
1498
1499 def realrun(self):
1480 if self.init: 1500 if self.init:
1481 self.init() 1501 self.init()
1482 1502
@@ -1577,7 +1597,7 @@ class CookerParser(object):
1577 self.feeder = Feeder(self.willparse, self.jobs, self.feeder_quit) 1597 self.feeder = Feeder(self.willparse, self.jobs, self.feeder_quit)
1578 self.feeder.start() 1598 self.feeder.start()
1579 for i in range(0, self.num_processes): 1599 for i in range(0, self.num_processes):
1580 parser = Parser(self.jobs, self.result_queue, self.parser_quit, init) 1600 parser = Parser(self.jobs, self.result_queue, self.parser_quit, init, self.cooker.configuration.profile)
1581 parser.start() 1601 parser.start()
1582 self.processes.append(parser) 1602 self.processes.append(parser)
1583 1603