| 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 telemetry import benchmark | 23 from telemetry import benchmark |
| 24 from telemetry import page as page_module | 24 from telemetry import page as page_module |
| 25 from telemetry.page import page_set | 25 from telemetry.page import page_set |
| 26 from telemetry.page import page_test | 26 from telemetry.page import page_test |
| 27 from telemetry.util import statistics | 27 from telemetry.util import statistics |
| 28 from telemetry.value import improvement_direction |
| 28 from telemetry.value import list_of_scalar_values | 29 from telemetry.value import list_of_scalar_values |
| 29 | 30 |
| 30 | 31 |
| 31 class _JetstreamMeasurement(page_test.PageTest): | 32 class _JetstreamMeasurement(page_test.PageTest): |
| 32 def __init__(self): | 33 def __init__(self): |
| 33 super(_JetstreamMeasurement, self).__init__( | 34 super(_JetstreamMeasurement, self).__init__( |
| 34 action_name_to_run='RunPageInteractions') | 35 action_name_to_run='RunPageInteractions') |
| 35 | 36 |
| 36 def WillNavigateToPage(self, page, tab): | 37 def WillNavigateToPage(self, page, tab): |
| 37 page.script_to_evaluate_on_commit = """ | 38 page.script_to_evaluate_on_commit = """ |
| (...skipping 19 matching lines...) Expand all Loading... |
| 57 tab.EvaluateJavaScript('JetStream.start()') | 58 tab.EvaluateJavaScript('JetStream.start()') |
| 58 tab.WaitForJavaScriptExpression(get_results_js, 600) | 59 tab.WaitForJavaScriptExpression(get_results_js, 600) |
| 59 | 60 |
| 60 result = tab.EvaluateJavaScript(get_results_js) | 61 result = tab.EvaluateJavaScript(get_results_js) |
| 61 result = json.loads(result.partition(': ')[2]) | 62 result = json.loads(result.partition(': ')[2]) |
| 62 | 63 |
| 63 all_score_lists = [] | 64 all_score_lists = [] |
| 64 for k, v in result.iteritems(): | 65 for k, v in result.iteritems(): |
| 65 results.AddValue(list_of_scalar_values.ListOfScalarValues( | 66 results.AddValue(list_of_scalar_values.ListOfScalarValues( |
| 66 results.current_page, k.replace('.', '_'), 'score', v['result'], | 67 results.current_page, k.replace('.', '_'), 'score', v['result'], |
| 67 important=False)) | 68 important=False, improvement_direction=improvement_direction.UP)) |
| 68 # Collect all test scores to compute geometric mean. | 69 # Collect all test scores to compute geometric mean. |
| 69 for i, score in enumerate(v['result']): | 70 for i, score in enumerate(v['result']): |
| 70 if len(all_score_lists) <= i: | 71 if len(all_score_lists) <= i: |
| 71 all_score_lists.append([]) | 72 all_score_lists.append([]) |
| 72 all_score_lists[i].append(score) | 73 all_score_lists[i].append(score) |
| 73 all_scores = [] | 74 all_scores = [] |
| 74 for score_list in all_score_lists: | 75 for score_list in all_score_lists: |
| 75 all_scores.append(statistics.GeometricMean(score_list)) | 76 all_scores.append(statistics.GeometricMean(score_list)) |
| 76 results.AddSummaryValue(list_of_scalar_values.ListOfScalarValues( | 77 results.AddSummaryValue(list_of_scalar_values.ListOfScalarValues( |
| 77 None, 'Score', 'score', all_scores)) | 78 None, 'Score', 'score', all_scores, |
| 79 improvement_direction=improvement_direction.UP)) |
| 78 | 80 |
| 79 | 81 |
| 80 @benchmark.Disabled('android', 'xp') # crbug.com/381742 | 82 @benchmark.Disabled('android', 'xp') # crbug.com/381742 |
| 81 class Jetstream(benchmark.Benchmark): | 83 class Jetstream(benchmark.Benchmark): |
| 82 test = _JetstreamMeasurement | 84 test = _JetstreamMeasurement |
| 83 | 85 |
| 84 def CreatePageSet(self, options): | 86 def CreatePageSet(self, options): |
| 85 ps = page_set.PageSet( | 87 ps = page_set.PageSet( |
| 86 archive_data_file='../page_sets/data/jetstream.json', | 88 archive_data_file='../page_sets/data/jetstream.json', |
| 87 file_path=os.path.abspath(__file__), | 89 file_path=os.path.abspath(__file__), |
| 88 bucket=page_set.INTERNAL_BUCKET) | 90 bucket=page_set.INTERNAL_BUCKET) |
| 89 ps.AddUserStory(page_module.Page( | 91 ps.AddUserStory(page_module.Page( |
| 90 'http://browserbench.org/JetStream/', ps, ps.base_dir, | 92 'http://browserbench.org/JetStream/', ps, ps.base_dir, |
| 91 make_javascript_deterministic=False)) | 93 make_javascript_deterministic=False)) |
| 92 return ps | 94 return ps |
| OLD | NEW |