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

Side by Side 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, 1 month 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """Tests for the Chromium Performance Dashboard data format implementation."""
6
7 import imp
8 import json
9 import os.path
10 import sys
11 import unittest
12
13 try:
14 imp.find_module("devtoolslib")
15 except ImportError:
16 sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
17
18 from devtoolslib.perf_dashboard import ChartDataRecorder
19
20 class ChartDataRecorderTest(unittest.TestCase):
21 """Tests the chart data recorder."""
22
23 def test_empty(self):
24 """Tests chart data with no charts."""
25 recorder = ChartDataRecorder()
26 result = json.loads(recorder.get_json())
27 self.assertEquals(0, len(result))
28
29 def test_one_chart(self):
30 """Tests chart data with two samples in one chart."""
31 recorder = ChartDataRecorder()
32 recorder.record_scalar('chart', 'val1', 'ms', 1)
33 recorder.record_scalar('chart', 'val2', 'ms', 2)
34
35 result = json.loads(recorder.get_json())
36 self.assertEquals(1, len(result))
37 self.assertEquals(2, len(result['chart']))
38 self.assertEquals({
39 'type': 'scalar',
40 'name': 'val1',
41 'units': 'ms',
42 'value': 1}, result['chart'][0])
43 self.assertEquals({
44 'type': 'scalar',
45 'name': 'val2',
46 'units': 'ms',
47 'value': 2}, result['chart'][1])
48
49 def test_two_charts(self):
50 """Tests chart data with two samples over two charts."""
51 recorder = ChartDataRecorder()
52 recorder.record_scalar('chart1', 'val1', 'ms', 1)
53 recorder.record_scalar('chart2', 'val2', 'ms', 2)
54
55 result = json.loads(recorder.get_json())
56 self.assertEquals(2, len(result))
57 self.assertEquals(1, len(result['chart1']))
58 self.assertEquals({
59 'type': 'scalar',
60 'name': 'val1',
61 'units': 'ms',
62 'value': 1}, result['chart1'][0])
63 self.assertEquals(1, len(result['chart2']))
64 self.assertEquals({
65 'type': 'scalar',
66 'name': 'val2',
67 'units': 'ms',
68 'value': 2}, result['chart2'][0])
OLDNEW
« 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