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

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

Issue 1435523002: Refactor mojo_benchmark. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/devtools/common/devtoolslib/benchmark.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/benchmark_unittest.py
diff --git a/mojo/devtools/common/devtoolslib/benchmark_unittest.py b/mojo/devtools/common/devtoolslib/benchmark_unittest.py
new file mode 100644
index 0000000000000000000000000000000000000000..625704134d043ffd0fb10128edf48d83d087771f
--- /dev/null
+++ b/mojo/devtools/common/devtoolslib/benchmark_unittest.py
@@ -0,0 +1,44 @@
+# 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 logic that drives runs of the benchmarking mojo app and parses
+its output."""
+
+import imp
+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 import benchmark
+
+
+class BenchmarkTest(unittest.TestCase):
+ """Tests the benchmark module."""
+
+ def test_parse_measurement_results_empty(self):
+ """Tests parsing empty output."""
+ output = """"""
+ results = benchmark._parse_measurement_results(output)
+ self.assertEquals({}, results)
+
+ def test_parse_measurement_results_typical(self):
+ """Tests parsing typical output with unrelated log entries."""
+ output = """
+[INFO:network_fetcher.cc(322)] Caching mojo app http://127.0.0.1:31839/benchmark.mojo at /usr/local/google/home/user/.mojo_url_response_disk_cache/cache/4F6FAE752C7958AE122C6A2D778F2014C15578250B3C6746D54B99E4F15A4458/4F6FAE752C7958AE122C6A2D778F2014C15578250B3C6746D54B99E4F15A4458
+[INFO:network_fetcher.cc(322)] Caching mojo app http://127.0.0.1:31839/dart_traced_application.mojo at /usr/local/google/home/user/.mojo_url_response_disk_cache/cache/AB290478907A1DC5434CBCFD053BE2E74254D882644E76B3C28E3E7E1BCDCC3D/AB290478907A1DC5434CBCFD053BE2E74254D882644E76B3C28E3E7E1BCDCC3D
+Observatory listening on http://127.0.0.1:38128
+[1109/155613:WARNING:event.cc(234)] Ignoring incorrect complete event (no duration)
+measurement: time_until/a/b 42.5
+measurement: time_between/a/b/c/d 21.1
+measurement: time_between/a/b/e/f FAILED
+some measurements failed
+"""
+ results = benchmark._parse_measurement_results(output)
+ self.assertEquals({'time_until/a/b': 42.5,
+ 'time_between/a/b/c/d': 21.1}, results)
« no previous file with comments | « mojo/devtools/common/devtoolslib/benchmark.py ('k') | mojo/devtools/common/mojo_benchmark » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698