From e36f1907c71cdde1872904a5e95fc10c65820deb Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Fri, 10 Jun 2011 16:22:54 +0000 Subject: [PATCH] bitbake: build.py: Dump out performance data of individual tasks (Bitbake rev: 32aa49519e4f015e3c21466a7e5dc939f6369851) Signed-off-by: Richard Purdie Signed-off-by: Richard Purdie --- bitbake/lib/bb/build.py | 18 ++++++++++++++++-- bitbake/lib/bb/runqueue.py | 3 ++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py index 2f6a61f..5f5a007 100644 --- a/bitbake/lib/bb/build.py +++ b/bitbake/lib/bb/build.py @@ -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: diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py index 0c7dfec..1bbe791 100644 --- a/bitbake/lib/bb/runqueue.py +++ b/bitbake/lib/bb/runqueue.py @@ -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) -- 2.7.4