bitbake: build.py: Dump out performance data of individual tasks
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 10 Jun 2011 16:22:54 +0000 (16:22 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 28 Jan 2013 14:49:05 +0000 (14:49 +0000)
(Bitbake rev: 32aa49519e4f015e3c21466a7e5dc939f6369851)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
bitbake/lib/bb/build.py
bitbake/lib/bb/runqueue.py

index 2f6a61f..5f5a007 100644 (file)
@@ -423,13 +423,27 @@ def _exec_task(fn, task, d, quieterr):
 
     return 0
 
-def exec_task(fn, task, d):
+def exec_task(fn, task, d, profile = False):
     try: 
         quieterr = False
         if d.getVarFlag(task, "quieterrors") is not None:
             quieterr = True
 
-        return _exec_task(fn, task, d, quieterr)
+        if profile: 
+            profname = "profile-%s.log" % (os.path.basename(fn) + "-" + task)
+            try:
+                import cProfile as profile
+            except:
+                import profile
+            prof = profile.Profile()
+            ret = profile.Profile.runcall(prof, _exec_task, fn, task, d, quieterr)
+            prof.dump_stats(profname)
+            bb.utils.process_profilelog(profname)
+
+            return ret
+        else:
+            return _exec_task(fn, task, d, quieterr)
+
     except Exception:
         from traceback import format_exc
         if not quieterr:
index 0c7dfec..1bbe791 100644 (file)
@@ -1149,7 +1149,8 @@ class RunQueueExecute:
                 os._exit(1)
             try:
                 if not self.cooker.configuration.dry_run:
-                    ret = bb.build.exec_task(fn, taskname, the_data)
+                    profile = self.cooker.configuration.profile
+                    ret = bb.build.exec_task(fn, taskname, the_data, profile)
                 os._exit(ret)
             except:
                 os._exit(1)