[llvm-commits] [zorg] r147464 - /zorg/trunk/lnt/lnt/server/reporting/analysis.py

Daniel Dunbar daniel at zuster.org
Tue Jan 3 11:10:18 PST 2012


Author: ddunbar
Date: Tue Jan  3 13:10:18 2012
New Revision: 147464

URL: http://llvm.org/viewvc/llvm-project?rev=147464&view=rev
Log:
[lnt/v0.4] lnt.server.ui/v4: Speed up report generation by not materializing Sample objects.

Modified:
    zorg/trunk/lnt/lnt/server/reporting/analysis.py

Modified: zorg/trunk/lnt/lnt/server/reporting/analysis.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/reporting/analysis.py?rev=147464&r1=147463&r2=147464&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/server/reporting/analysis.py (original)
+++ zorg/trunk/lnt/lnt/server/reporting/analysis.py Tue Jan  3 13:10:18 2012
@@ -16,8 +16,13 @@
 
     def get_run_comparison_result(self, run, compare_to, test_id, field,
                                   comparison_window=[]):
+        field_index = self.testsuite.sample_fields.index(field)
+
         # Get the field which indicates the requested field's status.
         status_field = field.status_field
+        if status_field:
+            status_field_index = self.testsuite.sample_fields.index(
+                status_field)
 
         # Load the sample data for the current and previous runs and the
         # comparison window.
@@ -43,13 +48,13 @@
         run_failed = prev_failed = False
         if status_field:
             for sample in run_samples:
-                run_failed |= sample.get_field(status_field) == FAIL
+                run_failed |= sample[status_field_index] == FAIL
             for sample in prev_samples:
-                prev_failed |= sample.get_field(status_field) == FAIL
+                prev_failed |= sample[status_field_index] == FAIL
 
         # Get the current and previous values.
-        run_values = [s.get_field(field) for s in run_samples]
-        prev_values = [s.get_field(field) for s in prev_samples]
+        run_values = [s[field_index] for s in run_samples]
+        prev_values = [s[field_index] for s in prev_samples]
         if run_values:
             run_value = min(run_values)
         else:
@@ -103,9 +108,9 @@
             # Filter out failing samples.
             if status_field:
                 prev_samples = [s for s in prev_samples
-                                if s.get_field(status_field) == PASS]
+                                if s[status_field_index] == PASS]
             if prev_samples:
-                prev_values = [s.get_field(field)
+                prev_values = [s[field_index]
                                for s in prev_samples]
                 stddev = stats.standard_deviation(prev_values)
                 MAD = stats.median_absolute_deviation(prev_values)
@@ -124,10 +129,19 @@
             return
 
         # Batch load all of the samples for the needed runs.
-        q = self.testsuite.query(self.testsuite.Sample)
+        #
+        # We speed things up considerably by loading the column data directly
+        # here instead of requiring SA to materialize Sample objects.
+        columns = [self.testsuite.Sample.run_id,
+                  self.testsuite.Sample.test_id]
+        columns.extend(f.column for f in self.testsuite.sample_fields)
+        q = self.testsuite.query(*columns)
         q = q.filter(self.testsuite.Sample.run_id.in_(to_load))
-        for sample in q:
-            self.sample_map[(sample.run_id, sample.test_id)] = sample
+        for data in q:
+            run_id = data[0]
+            test_id = data[1]
+            sample_values = data[2:]
+            self.sample_map[(run_id, test_id)] = sample_values
 
         self.loaded_run_ids |= to_load
 





More information about the llvm-commits mailing list