Perf-o-matic: don't query datastore to generate chart API urls
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Mar 2012 00:30:28 +0000 (00:30 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Mar 2012 00:30:28 +0000 (00:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=81499

Reviewed by Hajime Morita.

Parse json text to extract timestamps and test values instead of iterating
through the data store.

* Websites/webkit-perf.appspot.com/create_handler.py:
(CreateHandler.post):
* Websites/webkit-perf.appspot.com/models.py:
(Runs._timestamp_and_value_from_json_entry):
(Runs):
(Runs.to_json):
(Runs.chart_params):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@111473 268f45cc-cd09-0410-ab3c-d52691b4dbfc

ChangeLog
Websites/webkit-perf.appspot.com/create_handler.py
Websites/webkit-perf.appspot.com/models.py

index abee50d..900549c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2012-03-20  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Perf-o-matic: don't query datastore to generate chart API urls
+        https://bugs.webkit.org/show_bug.cgi?id=81499
+
+        Reviewed by Hajime Morita.
+
+        Parse json text to extract timestamps and test values instead of iterating
+        through the data store.
+
+        * Websites/webkit-perf.appspot.com/create_handler.py:
+        (CreateHandler.post):
+        * Websites/webkit-perf.appspot.com/models.py:
+        (Runs._timestamp_and_value_from_json_entry):
+        (Runs):
+        (Runs.to_json):
+        (Runs.chart_params):
+
 2012-03-20  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
 
         Convert hasSpellingMarker to use Internals interface.
index 1526ca6..5adafb7 100644 (file)
@@ -64,7 +64,7 @@ class CreateHandler(webapp2.RequestHandler):
 
         # No need to clear manifest or runs since they only contain ones with test results
         schedule_dashboard_update()
-        self.response.out.write(error + '\n' if error else 'OK')
+        self.response.out.write(error + '\n' if error else 'OK\n')
 
     def _create_builder(self, name, password):
         if not name or not password:
index df7ab7e..b25f12e 100644 (file)
@@ -356,6 +356,10 @@ class Runs(db.Model):
             builder_id, statistics]
 
     @staticmethod
+    def _timestamp_and_value_from_json_entry(json_entry):
+        return json_entry[2], json_entry[3]
+
+    @staticmethod
     def _key_name(branch_id, platform_id, test_id):
         return 'runs:%d,%d,%d' % (test_id, branch_id, platform_id)
 
@@ -417,7 +421,6 @@ class Runs(db.Model):
         return '{"test_runs": [%s], "averages": {%s}, "min": %s, "max": %s, "date_range": null, "stat": "ok"}' % (self.json_runs,
             self.json_averages, str(self.json_min) if self.json_min else 'null', str(self.json_max) if self.json_max else 'null')
 
-    # FIXME: Use data in JSON to compute values to avoid iterating through the datastore.
     def chart_params(self, display_days, now=datetime.now().replace(hour=12, minute=0, second=0, microsecond=0)):
         chart_data_x = []
         chart_data_y = []
@@ -425,12 +428,12 @@ class Runs(db.Model):
         start_timestamp = mktime((end_time - timedelta(display_days)).timetuple())
         end_timestamp = mktime(end_time.timetuple())
 
-        for build, result in self._generate_runs(self.branch, self.platform, self.test.name):
-            timestamp = mktime(build.timestamp.timetuple())
+        for entry in json.loads('[' + self.json_runs + ']'):
+            timestamp, value = Runs._timestamp_and_value_from_json_entry(entry)
             if timestamp < start_timestamp or timestamp > end_timestamp:
                 continue
             chart_data_x.append(timestamp)
-            chart_data_y.append(result.value)
+            chart_data_y.append(value)
 
         dates = [end_time - timedelta(display_days / 7.0 * (7 - i)) for i in range(0, 8)]