]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
toaster: update build stats reading
authorAlexandru DAMIAN <alexandru.damian@intel.com>
Wed, 27 Nov 2013 16:38:29 +0000 (16:38 +0000)
committerPaul Eggleton <paul.eggleton@linux.intel.com>
Mon, 9 Dec 2013 18:58:25 +0000 (18:58 +0000)
In the processes of removing local system accesses
from toaster UI, we remove the build stats
code that was moved to toaster.bbclass, and
adapt the database writing code to read the data
from BuildStatsList event sent by the toaster.bbclass

    [YOCTO #5604]

Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
lib/bb/ui/buildinfohelper.py
lib/bb/ui/toasterui.py

index b2e21ef2a68556f4051739691c1cc447fcbc0294..fef849d9a069bd93cd5e240a3b34192bb1e76350 100644 (file)
@@ -319,23 +319,16 @@ class BuildInfoHelper(object):
         assert False
         return None
 
-    def _get_recipe_information_from_build_event(self, event):
+    def _get_recipe_information_from_taskfile(self, taskfile):
 
-        layer_version_obj = self._get_layer_version_for_path(re.split(':', event.taskfile)[-1])
+        layer_version_obj = self._get_layer_version_for_path(re.split(':', taskfile)[-1])
 
         recipe_info = {}
         recipe_info['layer_version'] = layer_version_obj
-        recipe_info['file_path'] = re.split(':', event.taskfile)[-1]
+        recipe_info['file_path'] = re.split(':', taskfile)[-1]
 
         return recipe_info
 
-    def _get_task_build_stats(self, task_object):
-        bs_path = self._get_path_information(task_object)
-        for bp in bs_path:  # TODO: split for each target
-            task_build_stats = self._get_build_stats_from_file(bp, task_object.task_name)
-
-        return task_build_stats
-
     def _get_path_information(self, task_object):
         build_stats_format = "{tmpdir}/buildstats/{target}-{machine}/{buildname}/{package}/"
         build_stats_path = []
@@ -356,36 +349,6 @@ class BuildInfoHelper(object):
 
         return build_stats_path
 
-    def _get_build_stats_from_file(self, bs_path, task_name):
-
-        task_bs_filename = str(bs_path) + str(task_name)
-        task_bs = open(task_bs_filename, 'r')
-
-        cpu_usage = 0
-        disk_io = 0
-        startio = ''
-        endio = ''
-
-        for line in task_bs.readlines():
-            if line.startswith('CPU usage: '):
-                cpu_usage = line[11:]
-            elif line.startswith('EndTimeIO: '):
-                endio = line[11:]
-            elif line.startswith('StartTimeIO: '):
-                startio = line[13:]
-
-        task_bs.close()
-
-        if startio and endio:
-            disk_io = int(endio.strip('\n ')) - int(startio.strip('\n '))
-
-        if cpu_usage:
-            cpu_usage = float(cpu_usage.strip('% \n'))
-
-        task_build_stats = {'cpu_usage': cpu_usage, 'disk_io': disk_io}
-
-        return task_build_stats
-
     def _remove_redundant(self, string):
         ret = []
         for i in string.split():
@@ -435,7 +398,7 @@ class BuildInfoHelper(object):
     def store_started_task(self, event):
         identifier = event.taskfile + event.taskname
 
-        recipe_information = self._get_recipe_information_from_build_event(event)
+        recipe_information = self._get_recipe_information_from_taskfile(event.taskfile)
         recipe = self.orm_wrapper.get_update_recipe_object(recipe_information)
 
         task_information = self._get_task_information(event, recipe)
@@ -458,9 +421,23 @@ class BuildInfoHelper(object):
 
         self.internal_state[identifier] = {'start_time': datetime.datetime.now()}
 
+
+    def store_tasks_stats(self, event):
+        for (taskfile, taskname, taskstats) in event.data:
+            recipe_information = self._get_recipe_information_from_taskfile(taskfile)
+            recipe = self.orm_wrapper.get_update_recipe_object(recipe_information)
+
+            task_information = {}
+            task_information['build'] = self.internal_state['build']
+            task_information['recipe'] = recipe
+            task_information['task_name'] = taskname
+            task_information['cpu_usage'] = taskstats['cpu_usage']
+            task_information['disk_io'] = taskstats['disk_io']
+            task_obj = self.orm_wrapper.get_update_task_object(task_information)
+
     def update_and_store_task(self, event):
         identifier = event.taskfile + event.taskname
-        recipe_information = self._get_recipe_information_from_build_event(event)
+        recipe_information = self._get_recipe_information_from_taskfile(event.taskfile)
         recipe = self.orm_wrapper.get_update_recipe_object(recipe_information)
         task_information = self._get_task_information(event,recipe)
         try:
@@ -483,9 +460,6 @@ class BuildInfoHelper(object):
 
         if isinstance(event, (bb.runqueue.runQueueTaskCompleted, bb.runqueue.sceneQueueTaskCompleted)):
             task_information['outcome'] = Task.OUTCOME_SUCCESS
-            task_build_stats = self._get_task_build_stats(self.orm_wrapper.get_update_task_object(task_information))
-            task_information['cpu_usage'] = task_build_stats['cpu_usage']
-            task_information['disk_io'] = task_build_stats['disk_io']
             del self.internal_state[identifier]
 
         if isinstance(event, (bb.runqueue.runQueueTaskFailed, bb.runqueue.sceneQueueTaskFailed)):
index 50493e7b0ddea4fe64ad043fc5c779b317dc49c8..318fc28adb7bbbac1e8a2ed08e6fddb71e253b2c 100644 (file)
@@ -238,6 +238,8 @@ def main(server, eventHandler, params ):
                     buildinfohelper.store_build_package_information(event)
                 if event.type == "LayerInfo":
                     buildinfohelper.store_layer_info(event)
+                if event.type == "BuildStatsList":
+                    buildinfohelper.store_tasks_stats(event)
                 continue
 
             # ignore