Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(957)

Unified Diff: mojo/devtools/common/devtoolslib/perf_dashboard_unittest.py

Issue 1406063002: Teach mojo_benchmark to produce chart_data for the perf dashboard. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebase. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/devtools/common/devtoolslib/perf_dashboard.py ('k') | mojo/devtools/common/mojo_benchmark » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/devtools/common/devtoolslib/perf_dashboard_unittest.py
diff --git a/mojo/devtools/common/devtoolslib/perf_dashboard_unittest.py b/mojo/devtools/common/devtoolslib/perf_dashboard_unittest.py
new file mode 100644
index 0000000000000000000000000000000000000000..61809c370b61a5673303296586c3b823d83af883
--- /dev/null
+++ b/mojo/devtools/common/devtoolslib/perf_dashboard_unittest.py
@@ -0,0 +1,68 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Tests for the Chromium Performance Dashboard data format implementation."""
+
+import imp
+import json
+import os.path
+import sys
+import unittest
+
+try:
+ imp.find_module("devtoolslib")
+except ImportError:
+ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
+from devtoolslib.perf_dashboard import ChartDataRecorder
+
+class ChartDataRecorderTest(unittest.TestCase):
+ """Tests the chart data recorder."""
+
+ def test_empty(self):
+ """Tests chart data with no charts."""
+ recorder = ChartDataRecorder()
+ result = json.loads(recorder.get_json())
+ self.assertEquals(0, len(result))
+
+ def test_one_chart(self):
+ """Tests chart data with two samples in one chart."""
+ recorder = ChartDataRecorder()
+ recorder.record_scalar('chart', 'val1', 'ms', 1)
+ recorder.record_scalar('chart', 'val2', 'ms', 2)
+
+ result = json.loads(recorder.get_json())
+ self.assertEquals(1, len(result))
+ self.assertEquals(2, len(result['chart']))
+ self.assertEquals({
+ 'type': 'scalar',
+ 'name': 'val1',
+ 'units': 'ms',
+ 'value': 1}, result['chart'][0])
+ self.assertEquals({
+ 'type': 'scalar',
+ 'name': 'val2',
+ 'units': 'ms',
+ 'value': 2}, result['chart'][1])
+
+ def test_two_charts(self):
+ """Tests chart data with two samples over two charts."""
+ recorder = ChartDataRecorder()
+ recorder.record_scalar('chart1', 'val1', 'ms', 1)
+ recorder.record_scalar('chart2', 'val2', 'ms', 2)
+
+ result = json.loads(recorder.get_json())
+ self.assertEquals(2, len(result))
+ self.assertEquals(1, len(result['chart1']))
+ self.assertEquals({
+ 'type': 'scalar',
+ 'name': 'val1',
+ 'units': 'ms',
+ 'value': 1}, result['chart1'][0])
+ self.assertEquals(1, len(result['chart2']))
+ self.assertEquals({
+ 'type': 'scalar',
+ 'name': 'val2',
+ 'units': 'ms',
+ 'value': 2}, result['chart2'][0])
« no previous file with comments | « mojo/devtools/common/devtoolslib/perf_dashboard.py ('k') | mojo/devtools/common/mojo_benchmark » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698