Renamed perf_tools -> metrics, and *_metrics.py -> *_metric.py
BUG=
Review URL: https://chromiumcodereview.appspot.com/21205005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215170 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/tools/perf/measurements/loading_profile.py b/tools/perf/measurements/loading_profile.py
index ee0f339..ff818a20 100644
--- a/tools/perf/measurements/loading_profile.py
+++ b/tools/perf/measurements/loading_profile.py
@@ -5,7 +5,7 @@
import os
import tempfile
-from perf_tools import loading_metrics
+from metrics import loading
from telemetry.core import util
from telemetry.core.platform.profiler import perf_profiler
from telemetry.page import page_measurement
@@ -45,7 +45,7 @@
profile_files = tab.browser.StopProfiling()
- loading_metrics.AddResultsForTab(tab, results)
+ loading.AddResultsForTab(tab, results)
profile_file = None
for profile_file in profile_files:
diff --git a/tools/perf/measurements/loading_timeline.py b/tools/perf/measurements/loading_timeline.py
index cbf33d7a..c605abd6 100644
--- a/tools/perf/measurements/loading_timeline.py
+++ b/tools/perf/measurements/loading_timeline.py
@@ -1,8 +1,8 @@
# Copyright 2013 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.
-from perf_tools import timeline_metrics
-from perf_tools import loading_metrics
+from metrics import timeline
+from metrics import loading
from telemetry.core import util
from telemetry.page import page_measurement
@@ -16,8 +16,7 @@
return False
def WillNavigateToPage(self, page, tab):
- self._metrics = timeline_metrics.TimelineMetrics(
- timeline_metrics.TIMELINE_MODE)
+ self._metrics = timeline.TimelineMetrics(timeline.TIMELINE_MODE)
self._metrics.Start(tab)
def MeasurePage(self, page, tab, results):
@@ -31,5 +30,5 @@
# recognize loading as a toplevel action.
self._metrics.Stop(tab)
- loading_metrics.AddResultsForTab(tab, results)
+ loading.AddResultsForTab(tab, results)
self._metrics.AddResults(results)
diff --git a/tools/perf/measurements/loading_trace.py b/tools/perf/measurements/loading_trace.py
index 87de8c4..41aff21 100644
--- a/tools/perf/measurements/loading_trace.py
+++ b/tools/perf/measurements/loading_trace.py
@@ -1,8 +1,8 @@
# Copyright 2013 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.
-from perf_tools import loading_metrics
-from perf_tools import timeline_metrics
+from metrics import loading
+from metrics import timeline
from telemetry.core import util
from telemetry.page import page_measurement
@@ -16,8 +16,7 @@
return False
def WillNavigateToPage(self, page, tab):
- self._metrics = timeline_metrics.TimelineMetrics(
- timeline_metrics.TRACING_MODE)
+ self._metrics = timeline.TimelineMetrics(timeline.TRACING_MODE)
self._metrics.Start(tab)
def MeasurePage(self, page, tab, results):
@@ -31,5 +30,5 @@
# recognize loading as a toplevel action.
self._metrics.Stop(tab)
- loading_metrics.AddResultsForTab(tab, results)
+ loading.AddResultsForTab(tab, results)
self._metrics.AddResults(results)
diff --git a/tools/perf/measurements/media.py b/tools/perf/measurements/media.py
index 2f40b5b..5ac2048 100644
--- a/tools/perf/measurements/media.py
+++ b/tools/perf/measurements/media.py
@@ -4,10 +4,10 @@
"""Media measurement class gathers media related metrics on a page set.
-Media metrics recorded are controlled by media_metrics.js. At the end of the
+Media metrics recorded are controlled by metrics/media.js. At the end of the
test each metrics for every media element in the page are reported.
"""
-from perf_tools import media_metrics
+import metrics.media
from telemetry.page import page_measurement
@@ -25,7 +25,7 @@
def DidNavigateToPage(self, page, tab):
"""Override to do operations right after the page is navigated."""
- self.metrics = media_metrics.MediaMetrics(tab)
+ self.metrics = metrics.media.MediaMetrics(tab)
self.metrics.Start()
def MeasurePage(self, page, tab, results):
diff --git a/tools/perf/measurements/memory.py b/tools/perf/measurements/memory.py
index 3982e6d..0ce2b17a 100644
--- a/tools/perf/measurements/memory.py
+++ b/tools/perf/measurements/memory.py
@@ -1,7 +1,7 @@
# Copyright (c) 2012 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.
-from perf_tools import histogram_metric
+from metrics import histogram
from telemetry.page import page_measurement
@@ -20,11 +20,11 @@
def __init__(self):
super(Memory, self).__init__('stress_memory')
self.histograms = (
- [histogram_metric.HistogramMetric(
- h, histogram_metric.RENDERER_HISTOGRAM)
+ [histogram.HistogramMetric(
+ h, histogram.RENDERER_HISTOGRAM)
for h in MEMORY_HISTOGRAMS] +
- [histogram_metric.HistogramMetric(
- h, histogram_metric.BROWSER_HISTOGRAM)
+ [histogram.HistogramMetric(
+ h, histogram.BROWSER_HISTOGRAM)
for h in BROWSER_MEMORY_HISTOGRAMS])
def DidNavigateToPage(self, page, tab):
diff --git a/tools/perf/measurements/page_cycler.py b/tools/perf/measurements/page_cycler.py
index a0506d5..967a67b6 100644
--- a/tools/perf/measurements/page_cycler.py
+++ b/tools/perf/measurements/page_cycler.py
@@ -18,8 +18,8 @@
import os
import sys
-from perf_tools import histogram_metric
-from perf_tools import memory_metrics
+from metrics import histogram
+from metrics import memory
from telemetry.core import util
from telemetry.page import page_measurement
@@ -51,11 +51,11 @@
parser.add_option(pageset_repeat_option)
def DidStartBrowser(self, browser):
- self._memory_metrics = memory_metrics.MemoryMetrics()
+ self._memory_metrics = memory.MemoryMetrics()
self._memory_metrics.Start(browser)
- self._histograms = [histogram_metric.HistogramMetric(
- h, histogram_metric.RENDERER_HISTOGRAM)
+ self._histograms = [histogram.HistogramMetric(
+ h, histogram.RENDERER_HISTOGRAM)
for h in MEMORY_HISTOGRAMS]
def DidStartHTTPServer(self, tab):
diff --git a/tools/perf/measurements/rasterize_and_record.py b/tools/perf/measurements/rasterize_and_record.py
index ee1ddf9..600774e6 100644
--- a/tools/perf/measurements/rasterize_and_record.py
+++ b/tools/perf/measurements/rasterize_and_record.py
@@ -4,7 +4,7 @@
import time
-from perf_tools import smoothness_metrics
+from metrics import smoothness
from telemetry.page import page_measurement
class StatsCollector(object):
@@ -121,7 +121,7 @@
options.extra_browser_args.append('--enable-threaded-compositing')
def MeasurePage(self, page, tab, results):
- self._metrics = smoothness_metrics.SmoothnessMetrics(tab)
+ self._metrics = smoothness.SmoothnessMetrics(tab)
# Rasterize only what's visible.
tab.ExecuteJavaScript(
diff --git a/tools/perf/measurements/smoothness.py b/tools/perf/measurements/smoothness.py
index ffab630..71070b1 100644
--- a/tools/perf/measurements/smoothness.py
+++ b/tools/perf/measurements/smoothness.py
@@ -1,8 +1,8 @@
# Copyright (c) 2013 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.
-from perf_tools import loading_metrics
-from perf_tools import smoothness_metrics
+from metrics import loading
+from metrics import smoothness
from telemetry.page import page_measurement
class DidNotScrollException(page_measurement.MeasurementFailure):
@@ -38,7 +38,7 @@
def WillRunAction(self, page, tab, action):
if tab.browser.platform.IsRawDisplayFrameRateSupported():
tab.browser.platform.StartRawDisplayFrameRateMeasurement()
- self._metrics = smoothness_metrics.SmoothnessMetrics(tab)
+ self._metrics = smoothness.SmoothnessMetrics(tab)
if action.CanBeBound():
self._metrics.BindToAction(action)
else:
@@ -56,14 +56,14 @@
if not (rendering_stats_deltas['numFramesSentToScreen'] > 0):
raise DidNotScrollException()
- loading_metrics.AddResultsForTab(tab, results)
+ loading.AddResultsForTab(tab, results)
- smoothness_metrics.CalcFirstPaintTimeResults(results, tab)
- smoothness_metrics.CalcScrollResults(rendering_stats_deltas, results)
- smoothness_metrics.CalcTextureUploadResults(rendering_stats_deltas, results)
- smoothness_metrics.CalcImageDecodingResults(rendering_stats_deltas, results)
- smoothness_metrics.CalcAnalysisResults(rendering_stats_deltas, results)
- smoothness_metrics.CalcLatencyResults(rendering_stats_deltas, results)
+ smoothness.CalcFirstPaintTimeResults(results, tab)
+ smoothness.CalcScrollResults(rendering_stats_deltas, results)
+ smoothness.CalcTextureUploadResults(rendering_stats_deltas, results)
+ smoothness.CalcImageDecodingResults(rendering_stats_deltas, results)
+ smoothness.CalcAnalysisResults(rendering_stats_deltas, results)
+ smoothness.CalcLatencyResults(rendering_stats_deltas, results)
if self.options.report_all_results:
for k, v in rendering_stats_deltas.iteritems():
diff --git a/tools/perf/measurements/tab_switching.py b/tools/perf/measurements/tab_switching.py
index 9d036d8..20fc3c2 100644
--- a/tools/perf/measurements/tab_switching.py
+++ b/tools/perf/measurements/tab_switching.py
@@ -9,7 +9,7 @@
between when a tab was first requested to be shown, and when it was painted.
"""
-from perf_tools import histogram as histogram_module
+from metrics import histogram as histogram_module
from telemetry.core import util
from telemetry.page import page_measurement
from telemetry.page import page_runner
diff --git a/tools/perf/metrics/__init__.py b/tools/perf/metrics/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/perf/metrics/__init__.py
diff --git a/tools/perf/perf_tools/histogram_metric.py b/tools/perf/metrics/histogram.py
similarity index 83%
rename from tools/perf/perf_tools/histogram_metric.py
rename to tools/perf/metrics/histogram.py
index d7cb864..147ae96 100644
--- a/tools/perf/perf_tools/histogram_metric.py
+++ b/tools/perf/metrics/histogram.py
@@ -1,7 +1,7 @@
-# Copyright (c) 2013 The Chromium Authors. All rights reserved.
+# Copyright 2013 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.
-from perf_tools import histogram as histogram_module
+from metrics import histogram_util
BROWSER_HISTOGRAM = 'browser_histogram'
RENDERER_HISTOGRAM = 'renderer_histogram'
@@ -24,7 +24,7 @@
data = self._GetHistogramFromDomAutomation(tab)
if not data:
return
- new_histogram = histogram_module.SubtractHistogram(
+ new_histogram = histogram_util.SubtractHistogram(
data, self._start_values[page.url + self.name])
results.Add(self.name, self.units, new_histogram,
data_type='unimportant-histogram')
@@ -36,5 +36,5 @@
return 'getHistogram'
def _GetHistogramFromDomAutomation(self, tab):
- return histogram_module.GetHistogramFromDomAutomation(
+ return histogram_util.GetHistogramFromDomAutomation(
self.histogram_function, self.name, tab)
diff --git a/tools/perf/perf_tools/histogram.py b/tools/perf/metrics/histogram_util.py
similarity index 95%
rename from tools/perf/perf_tools/histogram.py
rename to tools/perf/metrics/histogram_util.py
index 6bfb5c2..5b72f5e 100644
--- a/tools/perf/perf_tools/histogram.py
+++ b/tools/perf/metrics/histogram_util.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2013 The Chromium Authors. All rights reserved.
+# Copyright 2013 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.
import json
diff --git a/tools/perf/perf_tools/histogram_unittest.py b/tools/perf/metrics/histogram_util_unittest.py
similarity index 85%
rename from tools/perf/perf_tools/histogram_unittest.py
rename to tools/perf/metrics/histogram_util_unittest.py
index f3f7829..7db5558 100644
--- a/tools/perf/perf_tools/histogram_unittest.py
+++ b/tools/perf/metrics/histogram_util_unittest.py
@@ -4,7 +4,7 @@
import json
import unittest
-from perf_tools import histogram as histogram_module
+from metrics import histogram_util
class TestHistogram(unittest.TestCase):
def testSubtractHistogram(self):
@@ -18,7 +18,7 @@
{"low": 3, "high": 4, "count": 10}]}"""
new_histogram = json.loads(
- histogram_module.SubtractHistogram(histogram, baseline_histogram))
+ histogram_util.SubtractHistogram(histogram, baseline_histogram))
new_buckets = dict()
for b in new_histogram['buckets']:
new_buckets[b['low']] = b['count']
diff --git a/tools/perf/perf_tools/loading_metrics.py b/tools/perf/metrics/loading.py
similarity index 100%
rename from tools/perf/perf_tools/loading_metrics.py
rename to tools/perf/metrics/loading.py
diff --git a/tools/perf/perf_tools/media_metrics.js b/tools/perf/metrics/media.js
similarity index 98%
rename from tools/perf/perf_tools/media_metrics.js
rename to tools/perf/metrics/media.js
index 0bbec91..7cef7cd0 100644
--- a/tools/perf/perf_tools/media_metrics.js
+++ b/tools/perf/metrics/media.js
@@ -1,4 +1,4 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2013 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.
diff --git a/tools/perf/perf_tools/media_metrics.py b/tools/perf/metrics/media.py
similarity index 92%
rename from tools/perf/perf_tools/media_metrics.py
rename to tools/perf/metrics/media.py
index 0d84727..3f3df23 100644
--- a/tools/perf/perf_tools/media_metrics.py
+++ b/tools/perf/metrics/media.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2013 The Chromium Authors. All rights reserved.
+# Copyright 2013 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.
@@ -16,7 +16,7 @@
class MediaMetrics(object):
def __init__(self, tab):
with open(
- os.path.join(os.path.dirname(__file__), 'media_metrics.js')) as f:
+ os.path.join(os.path.dirname(__file__), 'media.js')) as f:
js = f.read()
tab.ExecuteJavaScript(js)
self.tab = tab
diff --git a/tools/perf/perf_tools/memory_metrics.py b/tools/perf/metrics/memory.py
similarity index 100%
rename from tools/perf/perf_tools/memory_metrics.py
rename to tools/perf/metrics/memory.py
diff --git a/tools/perf/perf_tools/smoothness_metrics.js b/tools/perf/metrics/smoothness.js
similarity index 97%
rename from tools/perf/perf_tools/smoothness_metrics.js
rename to tools/perf/metrics/smoothness.js
index 22336fee..833ac06 100644
--- a/tools/perf/perf_tools/smoothness_metrics.js
+++ b/tools/perf/metrics/smoothness.js
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2013 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.
diff --git a/tools/perf/perf_tools/smoothness_metrics.py b/tools/perf/metrics/smoothness.py
similarity index 97%
rename from tools/perf/perf_tools/smoothness_metrics.py
rename to tools/perf/metrics/smoothness.py
index e55d7ab..f4ebfbc 100644
--- a/tools/perf/perf_tools/smoothness_metrics.py
+++ b/tools/perf/metrics/smoothness.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Copyright 2013 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.
import os
@@ -10,7 +10,7 @@
self._tab = tab
with open(
os.path.join(os.path.dirname(__file__),
- 'smoothness_metrics.js')) as f:
+ 'smoothness.js')) as f:
js = f.read()
tab.ExecuteJavaScript(js)
diff --git a/tools/perf/perf_tools/smoothness_metrics_unittest.py b/tools/perf/metrics/smoothness_unittest.py
similarity index 91%
rename from tools/perf/perf_tools/smoothness_metrics_unittest.py
rename to tools/perf/metrics/smoothness_unittest.py
index 6b8f985..e7b8778 100644
--- a/tools/perf/perf_tools/smoothness_metrics_unittest.py
+++ b/tools/perf/metrics/smoothness_unittest.py
@@ -3,7 +3,7 @@
# found in the LICENSE file.
import unittest
-from perf_tools import smoothness_metrics
+from metrics import smoothness
from telemetry.page import page
from telemetry.page.page_measurement_results import PageMeasurementResults
@@ -16,7 +16,7 @@
'numFramesSentToScreen': 10}
res = PageMeasurementResults()
res.WillMeasurePage(page.Page('http://foo.com/', None))
- smoothness_metrics.CalcScrollResults(rendering_stats, res)
+ smoothness.CalcScrollResults(rendering_stats, res)
res.DidMeasurePage()
self.assertEquals(50, res.page_results[0]['dropped_percent'].value)
self.assertAlmostEquals(
@@ -38,7 +38,7 @@
'totalTimeInSeconds': 1.0}
res = PageMeasurementResults()
res.WillMeasurePage(page.Page('http://foo.com/', None))
- smoothness_metrics.CalcScrollResults(rendering_stats, res)
+ smoothness.CalcScrollResults(rendering_stats, res)
res.DidMeasurePage()
self.assertEquals(0, res.page_results[0]['dropped_percent'].value)
self.assertAlmostEquals(
diff --git a/tools/perf/perf_tools/timeline_metrics.py b/tools/perf/metrics/timeline.py
similarity index 100%
rename from tools/perf/perf_tools/timeline_metrics.py
rename to tools/perf/metrics/timeline.py
diff --git a/tools/perf/perf_tools/bootstrap_deps b/tools/perf/perf_tools/bootstrap_deps
index 1ca411e..18234083 100644
--- a/tools/perf/perf_tools/bootstrap_deps
+++ b/tools/perf/perf_tools/bootstrap_deps
@@ -2,9 +2,9 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-# This file specifies dependencies required to bootstrap perf_tools. It is in a
+# This file specifies dependencies required to bootstrap tools/perf. It is in a
# minimal version of the format used by other DEPS files that gclient can read,
-# but it should only be used to bootstrap perf_tools *outside* of a normal
+# but it should only be used to bootstrap tools/perf *outside* of a normal
# Chrome checkout.
deps = {
@@ -14,13 +14,15 @@
"https://src.chromium.org/chrome/trunk/src/tools/perf/measurements",
"src/tools/perf/page_sets":
"https://src.chromium.org/chrome/trunk/src/tools/perf/page_sets",
+ "src/tools/perf/metrics":
+ "https://src.chromium.org/chrome/trunk/src/tools/perf/metrics",
"src/tools/perf/perf_tools":
"https://src.chromium.org/chrome/trunk/src/tools/perf/perf_tools",
"src/tools/perf/profile_creators":
"https://src.chromium.org/chrome/trunk/src/tools/perf/profile_creators",
}
-# perf_tools depends on Telemetry, so pull in the Telemetry deps, too.
+# tools/perf depends on Telemetry, so pull in the Telemetry deps, too.
deps_includes = {
"src/tools/telemetry_tools/bootstrap_deps":
"https://src.chromium.org/chrome/trunk/src/tools/telemetry_tools/bootstrap_deps",
diff --git a/tools/perf/record_wpr b/tools/perf/record_wpr
index f73928a9..e12055f 100755
--- a/tools/perf/record_wpr
+++ b/tools/perf/record_wpr
@@ -5,8 +5,13 @@
import os
import sys
-import perf_tools
+# Add telemetry to sys.path so that it can be imported below
+# Relative path from this file is ../telemetry
+_perf_dir = os.path.dirname(__file__)
+_telemetry_path = os.path.join(_perf_dir, os.pardir, 'telemetry')
+sys.path.append(_telemetry_path)
+
from telemetry.page import record_wpr
if __name__ == '__main__':
- sys.exit(record_wpr.Main(os.path.dirname(__file__)))
+ sys.exit(record_wpr.Main(_perf_dir))
diff --git a/tools/perf/run_measurement b/tools/perf/run_measurement
index 3c66495..8893fcd 100755
--- a/tools/perf/run_measurement
+++ b/tools/perf/run_measurement
@@ -40,6 +40,11 @@
Returns: a list of telemetry deps.
"""
+ # Add telemetry_tools to sys.path for the import below
+ telemetry_tools_path = os.path.join(os.path.dirname(__file__),
+ os.pardir, 'telemetry_tools')
+ sys.path.append(telemetry_tools_path)
+
import perf_tools
import telemetry_bootstrap
deps_file = os.path.join(os.path.dirname(perf_tools.__file__),
@@ -50,7 +55,12 @@
BootstrapIfNeeded('perf_tools', PERF_DIR,
'http://src.chromium.org/viewvc/chrome/trunk/src/tools'
'/perf/perf_tools/' + DEPS_FILE)
- import perf_tools
+
+ # Add telemetry to sys.path for the import below
+ telemetry_path = os.path.join(os.path.dirname(__file__),
+ os.pardir, 'telemetry')
+ sys.path.append(telemetry_path)
+
if '--print-bootstrap-deps' in sys.argv:
print ListBootstrapDeps()
sys.exit(0)