bitbake: cooker: Allow profiling of the parser in profile mode
(Bitbake rev: f8a6e4caed4dc3dcf207aecc4ea5f438027da8be) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
eb4854f903
commit
602bb695cf
|
@ -1467,7 +1467,7 @@ class Feeder(multiprocessing.Process):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
class Parser(multiprocessing.Process):
|
class Parser(multiprocessing.Process):
|
||||||
def __init__(self, jobs, results, quit, init):
|
def __init__(self, jobs, results, quit, init, profile):
|
||||||
self.jobs = jobs
|
self.jobs = jobs
|
||||||
self.results = results
|
self.results = results
|
||||||
self.quit = quit
|
self.quit = quit
|
||||||
|
@ -1475,8 +1475,28 @@ class Parser(multiprocessing.Process):
|
||||||
multiprocessing.Process.__init__(self)
|
multiprocessing.Process.__init__(self)
|
||||||
self.context = bb.utils.get_context().copy()
|
self.context = bb.utils.get_context().copy()
|
||||||
self.handlers = bb.event.get_class_handlers().copy()
|
self.handlers = bb.event.get_class_handlers().copy()
|
||||||
|
self.profile = profile
|
||||||
|
|
||||||
def run(self):
|
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:
|
if self.init:
|
||||||
self.init()
|
self.init()
|
||||||
|
|
||||||
|
@ -1577,7 +1597,7 @@ class CookerParser(object):
|
||||||
self.feeder = Feeder(self.willparse, self.jobs, self.feeder_quit)
|
self.feeder = Feeder(self.willparse, self.jobs, self.feeder_quit)
|
||||||
self.feeder.start()
|
self.feeder.start()
|
||||||
for i in range(0, self.num_processes):
|
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()
|
parser.start()
|
||||||
self.processes.append(parser)
|
self.processes.append(parser)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue