| OLD | NEW |
| 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 | 4 |
| 5 """Runs Apple's JetStream benchmark. | 5 """Runs Apple's JetStream benchmark. |
| 6 | 6 |
| 7 JetStream combines a variety of JavaScript benchmarks, covering a variety of | 7 JetStream combines a variety of JavaScript benchmarks, covering a variety of |
| 8 advanced workloads and programming techniques, and reports a single score that | 8 advanced workloads and programming techniques, and reports a single score that |
| 9 balances them using geometric mean. | 9 balances them using geometric mean. |
| 10 | 10 |
| 11 Each benchmark measures a distinct workload, and no single optimization | 11 Each benchmark measures a distinct workload, and no single optimization |
| 12 technique is sufficient to speed up all benchmarks. Latency tests measure that | 12 technique is sufficient to speed up all benchmarks. Latency tests measure that |
| 13 a web application can start up quickly, ramp up to peak performance quickly, | 13 a web application can start up quickly, ramp up to peak performance quickly, |
| 14 and run smoothly without interruptions. Throughput tests measure the sustained | 14 and run smoothly without interruptions. Throughput tests measure the sustained |
| 15 peak performance of a web application, ignoring ramp-up time and spikes in | 15 peak performance of a web application, ignoring ramp-up time and spikes in |
| 16 smoothness. Some benchmarks demonstrate tradeoffs, and aggressive or | 16 smoothness. Some benchmarks demonstrate tradeoffs, and aggressive or |
| 17 specialized optimization for one benchmark might make another benchmark slower. | 17 specialized optimization for one benchmark might make another benchmark slower. |
| 18 """ | 18 """ |
| 19 | 19 |
| 20 import json | 20 import json |
| 21 import os | 21 import os |
| 22 | 22 |
| 23 from measurements import PageTestMeasurement |
| 23 from telemetry import benchmark | 24 from telemetry import benchmark |
| 24 from telemetry.page import page_set | 25 from telemetry.page import page_set |
| 25 from telemetry.page import page_test | |
| 26 from telemetry.util import statistics | 26 from telemetry.util import statistics |
| 27 from telemetry.value import list_of_scalar_values | 27 from telemetry.value import list_of_scalar_values |
| 28 | 28 |
| 29 | 29 |
| 30 class _JetstreamMeasurement(page_test.PageTest): | 30 class _JetstreamMeasurement(PageTestMeasurement): |
| 31 def __init__(self): | 31 def __init__(self): |
| 32 super(_JetstreamMeasurement, self).__init__() | 32 super(_JetstreamMeasurement, self).__init__() |
| 33 | 33 |
| 34 def WillNavigateToPage(self, page, tab): | 34 def WillNavigateToPage(self, page, tab): |
| 35 page.script_to_evaluate_on_commit = """ | 35 page.script_to_evaluate_on_commit = """ |
| 36 var __results = []; | 36 var __results = []; |
| 37 var __real_log = window.console.log; | 37 var __real_log = window.console.log; |
| 38 window.console.log = function() { | 38 window.console.log = function() { |
| 39 __results.push(Array.prototype.join.call(arguments, ' ')); | 39 __results.push(Array.prototype.join.call(arguments, ' ')); |
| 40 __real_log.apply(this, arguments); | 40 __real_log.apply(this, arguments); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 66 # Collect all test scores to compute geometric mean. | 66 # Collect all test scores to compute geometric mean. |
| 67 for i, score in enumerate(v['result']): | 67 for i, score in enumerate(v['result']): |
| 68 if len(all_score_lists) <= i: | 68 if len(all_score_lists) <= i: |
| 69 all_score_lists.append([]) | 69 all_score_lists.append([]) |
| 70 all_score_lists[i].append(score) | 70 all_score_lists[i].append(score) |
| 71 all_scores = [] | 71 all_scores = [] |
| 72 for score_list in all_score_lists: | 72 for score_list in all_score_lists: |
| 73 all_scores.append(statistics.GeometricMean(score_list)) | 73 all_scores.append(statistics.GeometricMean(score_list)) |
| 74 results.AddSummaryValue(list_of_scalar_values.ListOfScalarValues( | 74 results.AddSummaryValue(list_of_scalar_values.ListOfScalarValues( |
| 75 None, 'Score', 'score', all_scores)) | 75 None, 'Score', 'score', all_scores)) |
| 76 super(_JetstreamMeasurement, self).ValidateAndMeasurePage( |
| 77 page, tab, results) |
| 76 | 78 |
| 77 | 79 |
| 78 @benchmark.Disabled('android', 'xp') # crbug.com/381742 | 80 @benchmark.Disabled('android', 'xp') # crbug.com/381742 |
| 79 class Jetstream(benchmark.Benchmark): | 81 class Jetstream(benchmark.Benchmark): |
| 80 test = _JetstreamMeasurement | 82 test = _JetstreamMeasurement |
| 81 | 83 |
| 82 def CreatePageSet(self, options): | 84 def CreatePageSet(self, options): |
| 83 ps = page_set.PageSet( | 85 ps = page_set.PageSet( |
| 84 archive_data_file='../page_sets/data/jetstream.json', | 86 archive_data_file='../page_sets/data/jetstream.json', |
| 85 make_javascript_deterministic=False, | 87 make_javascript_deterministic=False, |
| 86 file_path=os.path.abspath(__file__)) | 88 file_path=os.path.abspath(__file__)) |
| 87 ps.AddPageWithDefaultRunNavigate('http://browserbench.org/JetStream/') | 89 ps.AddPageWithDefaultRunNavigate('http://browserbench.org/JetStream/') |
| 88 return ps | 90 return ps |
| OLD | NEW |