1 # Copyright (c) 2012 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.
5 from telemetry
.page
import page_benchmark
8 class ImageDecoding(page_benchmark
.PageBenchmark
):
9 def WillNavigateToPage(self
, page
, tab
):
10 tab
.StartTimelineRecording()
12 def MeasurePage(self
, page
, tab
, results
):
13 tab
.StopTimelineRecording()
15 return tab
.EvaluateJavaScript('isDone')
17 decode_image_events
= \
18 tab
.timeline_model
.GetAllOfName('DecodeImage')
20 # If it is a real image benchmark, then store only the last-minIterations
23 'image_decoding_benchmark_limit_results_to_min_iterations') and
24 page
.image_decoding_benchmark_limit_results_to_min_iterations
):
26 min_iterations
= tab
.EvaluateJavaScript('minIterations')
27 decode_image_events
= decode_image_events
[-min_iterations
:]
29 durations
= [d
.duration_ms
for d
in decode_image_events
]
31 results
.Add('ImageDecoding_avg', 'ms', 'unsupported')
33 image_decoding_avg
= sum(durations
) / len(durations
)
34 results
.Add('ImageDecoding_avg', 'ms', image_decoding_avg
)