All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/16] cooker: Allow profiling of the parser in profile mode
@ 2013-09-16 21:53 Richard Purdie
  2013-09-16 21:53 ` [PATCH 02/16] data: Be explicit in data_db check Richard Purdie
                   ` (14 more replies)
  0 siblings, 15 replies; 17+ messages in thread
From: Richard Purdie @ 2013-09-16 21:53 UTC (permalink / raw)
  To: bitbake-devel

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/cooker.py | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index a07615b..2c8d4dc 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -1480,7 +1480,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
@@ -1488,8 +1488,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()
 
@@ -1590,7 +1610,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)
 
-- 
1.8.1.2



^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2013-09-17  9:42 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-16 21:53 [PATCH 01/16] cooker: Allow profiling of the parser in profile mode Richard Purdie
2013-09-16 21:53 ` [PATCH 02/16] data: Be explicit in data_db check Richard Purdie
2013-09-16 21:53 ` [PATCH 03/16] siggen: Use lookup cache exclusively Richard Purdie
2013-09-16 21:53 ` [PATCH 04/16] data_smart: Improve variable expansion regexp Richard Purdie
2013-09-16 21:53 ` [PATCH 05/16] data_smart: use the expand_cache in VariableParse Richard Purdie
2013-09-16 21:53 ` [PATCH 06/16] data: Use direct iteration, not keys() Richard Purdie
2013-09-16 21:53 ` [PATCH 07/16] data: Cache an list of export variables Richard Purdie
2013-09-16 21:53 ` [PATCH 08/16] data_smart: Add explict None checks Richard Purdie
2013-09-16 21:53 ` [PATCH 09/16] data_smart: Allow expansion of flags in getVarFlags Richard Purdie
2013-09-16 21:53 ` [PATCH 10/16] data_smart: Allow flags to use the expand cache Richard Purdie
2013-09-16 21:53 ` [PATCH 11/16] data_smart: Cache the fact a variable accesses another even if its unset Richard Purdie
2013-09-16 21:53 ` [PATCH 12/16] data: Optimise build_dependencies a little Richard Purdie
2013-09-16 21:53 ` [PATCH 13/16] data: Optimise flag lookup in build_dependencies Richard Purdie
2013-09-16 21:53 ` [PATCH 14/16] data: Optimise flag exclusion list handling Richard Purdie
2013-09-16 21:53 ` [PATCH 15/16] bitbake: bb.fatal: Raise a BBHandledException instead of exiting Richard Purdie
2013-09-16 21:53 ` [PATCH 16/16] bitbake: bb: Drop deprecated functions Richard Purdie
2013-09-17  9:42   ` Richard Purdie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.