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

Side by Side Diff: tools/perf/measurements/screenshot.py

Issue 668753002: [Telemetry] Migrate bitmap.py from bitmaptools.cc to numpy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years 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 | « content/test/gpu/gpu_tests/pixel.py ('k') | tools/perf/metrics/speedindex.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 import os 4 import os
5 5
6 from telemetry.image_processing import image_util
6 from telemetry.page import page_test 7 from telemetry.page import page_test
7 from telemetry.page import page_test 8 from telemetry.page import page_test
8 from telemetry.value import scalar 9 from telemetry.value import scalar
9 10
10 11
11 class Screenshot(page_test.PageTest): 12 class Screenshot(page_test.PageTest):
12 def __init__(self, png_outdir): 13 def __init__(self, png_outdir):
13 super(Screenshot, self).__init__( 14 super(Screenshot, self).__init__(
14 action_name_to_run = 'RunPageInteractions', 15 action_name_to_run = 'RunPageInteractions',
15 is_action_name_to_run_optional=True) 16 is_action_name_to_run_optional=True)
16 self._png_outdir = png_outdir 17 self._png_outdir = png_outdir
17 18
18 def ValidateAndMeasurePage(self, page, tab, results): 19 def ValidateAndMeasurePage(self, page, tab, results):
19 if not tab.screenshot_supported: 20 if not tab.screenshot_supported:
20 raise page_test.TestNotSupportedOnPlatformError( 21 raise page_test.TestNotSupportedOnPlatformError(
21 'Browser does not support screenshotting') 22 'Browser does not support screenshotting')
22 23
23 tab.WaitForDocumentReadyStateToBeComplete() 24 tab.WaitForDocumentReadyStateToBeComplete()
24 screenshot = tab.Screenshot(60) 25 screenshot = tab.Screenshot(60)
25 26
26 outpath = os.path.abspath( 27 outpath = os.path.abspath(
27 os.path.join(self._png_outdir, page.file_safe_name)) + '.png' 28 os.path.join(self._png_outdir, page.file_safe_name)) + '.png'
28 29
29 if os.path.exists(outpath): 30 if os.path.exists(outpath):
30 previous_mtime = os.path.getmtime(outpath) 31 previous_mtime = os.path.getmtime(outpath)
31 else: 32 else:
32 previous_mtime = -1 33 previous_mtime = -1
33 34
34 screenshot.WritePngFile(outpath) 35 image_util.WritePngFile(screenshot, outpath)
35 36
36 saved_picture_count = 0 37 saved_picture_count = 0
37 if os.path.exists(outpath) and os.path.getmtime(outpath) > previous_mtime: 38 if os.path.exists(outpath) and os.path.getmtime(outpath) > previous_mtime:
38 saved_picture_count = 1 39 saved_picture_count = 1
39 results.AddValue(scalar.ScalarValue( 40 results.AddValue(scalar.ScalarValue(
40 results.current_page, 'saved_picture_count', 'count', 41 results.current_page, 'saved_picture_count', 'count',
41 saved_picture_count)) 42 saved_picture_count))
OLDNEW
« no previous file with comments | « content/test/gpu/gpu_tests/pixel.py ('k') | tools/perf/metrics/speedindex.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698