diff options
author | nduca@chromium.org <nduca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-07 22:38:54 +0000 |
---|---|---|
committer | nduca@chromium.org <nduca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-07 22:38:54 +0000 |
commit | 18d8eef0e3c223361c60efabe1be0a7164aca024 (patch) | |
tree | 27848c25da97da6efc28f6ebb0f92df443e28d52 /tools | |
parent | b448570bda3202d6181500c79e201f4228feef9e (diff) | |
download | chromium_src-18d8eef0e3c223361c60efabe1be0a7164aca024.zip chromium_src-18d8eef0e3c223361c60efabe1be0a7164aca024.tar.gz chromium_src-18d8eef0e3c223361c60efabe1be0a7164aca024.tar.bz2 |
[telemetry] Clean up image decoding benchmark
The image decoding benchmark still contained some logic for navigation/test
control. The image_decoding_benchmark should measure image decodign times. Critically, the
logic to make chrome/test/data/image_decoding/image_decoding.html do its work
should be handled by the page runner, not the benchmark. To make this
separation happen, three changes are made...
First, page runner now notifies the test that naivgation will happen. This
allows us to begin recording the timeline right before navigation. This is when timeline
recording should begin for image decode tests.
Second, this adds a post_navigate_javascript_to_execute method to the page. This allows us to
call runBenchmark() on the image decoding benchmarks after we navigate.
Finally, the benchmark uses the standard wait_for_javascript_expression to poll
the isDone variable.The old code actually did this in python.
R=tonyg
NOTRY=True
Review URL: https://chromiumcodereview.appspot.com/11753023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175404 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/page_sets/image_decoding_benchmark.json | 23 | ||||
-rw-r--r-- | tools/perf/page_sets/image_stress_tests.json | 12 | ||||
-rw-r--r-- | tools/perf/page_sets/tough_image_cases.json | 23 | ||||
-rw-r--r-- | tools/perf/perf_tools/image_decoding_benchmark.py | 26 | ||||
-rw-r--r-- | tools/telemetry/telemetry/page.py | 3 | ||||
-rw-r--r-- | tools/telemetry/telemetry/page_runner.py | 7 | ||||
-rw-r--r-- | tools/telemetry/telemetry/page_test.py | 9 |
7 files changed, 89 insertions, 14 deletions
diff --git a/tools/perf/page_sets/image_decoding_benchmark.json b/tools/perf/page_sets/image_decoding_benchmark.json new file mode 100644 index 0000000..7cf6f6b --- /dev/null +++ b/tools/perf/page_sets/image_decoding_benchmark.json @@ -0,0 +1,23 @@ +{ + "description": "A directed benchmark of image decoding performance", + "pages": [ + { + "url": "file:///../../../chrome/test/data/image_decoding/image_decoding.html?gif", + "post_navigate_javascript_to_execute": "runBenchmark();", + "wait_for_javascript_expression": "isDone", + "image_decoding_benchmark_limit_results_to_min_iterations": true + }, + { + "url": "file:///../../../chrome/test/data/image_decoding/image_decoding.html?jpg", + "post_navigate_javascript_to_execute": "runBenchmark();", + "wait_for_javascript_expression": "isDone", + "image_decoding_benchmark_limit_results_to_min_iterations": true + }, + { + "url": "file:///../../../chrome/test/data/image_decoding/image_decoding.html?png", + "post_navigate_javascript_to_execute": "runBenchmark();", + "wait_for_javascript_expression": "isDone", + "image_decoding_benchmark_limit_results_to_min_iterations": true + } + ] +} diff --git a/tools/perf/page_sets/image_stress_tests.json b/tools/perf/page_sets/image_stress_tests.json new file mode 100644 index 0000000..a131248 --- /dev/null +++ b/tools/perf/page_sets/image_stress_tests.json @@ -0,0 +1,12 @@ +{ + "description": "A collection of image-heavy sites.", + "user_agent_type": "desktop", + "pages": [ + { + "url": "http://www.free-pictures-photos.com/aviation/airplane-306.jpg" + }, + { + "url": "http://upload.wikimedia.org/wikipedia/commons/c/cb/General_history%2C_Alaska_Yukon_Pacific_Exposition%2C_fully_illustrated_-_meet_me_in_Seattle_1909_-_Page_78.jpg" + } + ] +} diff --git a/tools/perf/page_sets/tough_image_cases.json b/tools/perf/page_sets/tough_image_cases.json index 036233c..9077e6a 100644 --- a/tools/perf/page_sets/tough_image_cases.json +++ b/tools/perf/page_sets/tough_image_cases.json @@ -1,8 +1,23 @@ { - "description": "A collection of image decoding performance tests", + "description": "**THIS IS OBSOLETE, EDIT image_decoding_benchmark.json instead***", "pages": [ - {"url": "file:///../../../chrome/test/data/image_decoding/image_decoding.html?gif"}, - {"url": "file:///../../../chrome/test/data/image_decoding/image_decoding.html?jpg"}, - {"url": "file:///../../../chrome/test/data/image_decoding/image_decoding.html?png"} + { + "url": "file:///../../../chrome/test/data/image_decoding/image_decoding.html?gif", + "post_navigate_javascript_to_execute": "runBenchmark();", + "wait_for_javascript_expression": "isDone", + "image_decoding_benchmark_limit_results_to_min_iterations": true + }, + { + "url": "file:///../../../chrome/test/data/image_decoding/image_decoding.html?jpg", + "post_navigate_javascript_to_execute": "runBenchmark();", + "wait_for_javascript_expression": "isDone", + "image_decoding_benchmark_limit_results_to_min_iterations": true + }, + { + "url": "file:///../../../chrome/test/data/image_decoding/image_decoding.html?png", + "post_navigate_javascript_to_execute": "runBenchmark();", + "wait_for_javascript_expression": "isDone", + "image_decoding_benchmark_limit_results_to_min_iterations": true + } ] } diff --git a/tools/perf/perf_tools/image_decoding_benchmark.py b/tools/perf/perf_tools/image_decoding_benchmark.py index e231134..c0df84e 100644 --- a/tools/perf/perf_tools/image_decoding_benchmark.py +++ b/tools/perf/perf_tools/image_decoding_benchmark.py @@ -3,20 +3,30 @@ # found in the LICENSE file. from telemetry import multi_page_benchmark -from telemetry import util class ImageDecoding(multi_page_benchmark.MultiPageBenchmark): - def MeasurePage(self, _, tab, results): + def WillNavigateToPage(self, page, tab): + tab.timeline.Start() + + def MeasurePage(self, page, tab, results): + tab.timeline.Stop() def _IsDone(): return tab.runtime.Evaluate('isDone') - with tab.timeline.Recorder(tab.timeline): - tab.runtime.Execute('runBenchmark()') - util.WaitFor(_IsDone, 60) - iterations = tab.runtime.Evaluate('minIterations') - decode_image = tab.timeline.timeline_events.GetAllOfType('DecodeImage') - elapsed_times = [d.elapsed_time for d in decode_image[-iterations:]] + decode_image_events = \ + tab.timeline.timeline_events.GetAllOfType('DecodeImage') + + # If it is a real image benchmark, then store only the last-minIterations + # decode tasks. + if (hasattr(page, + 'image_decoding_benchmark_limit_results_to_min_iterations') and + page.image_decoding_benchmark_limit_results_to_min_iterations): + assert _IsDone() + min_iterations = tab.runtime.Evaluate('minIterations') + decode_image_events = decode_image_events[-min_iterations:] + + elapsed_times = [d.elapsed_time for d in decode_image_events] if not elapsed_times: results.Add('ImageDecoding_avg', 'ms', 'unsupported') return diff --git a/tools/telemetry/telemetry/page.py b/tools/telemetry/telemetry/page.py index 08b634d..a59da61 100644 --- a/tools/telemetry/telemetry/page.py +++ b/tools/telemetry/telemetry/page.py @@ -67,6 +67,9 @@ class Page(object): @staticmethod def WaitForPageToLoad(obj, tab, timeout, poll_interval=0.1): """Waits for various wait conditions present in obj.""" + if hasattr(obj, 'post_navigate_javascript_to_execute'): + tab.runtime.Evaluate(obj.post_navigate_javascript_to_execute) + if hasattr(obj, 'wait_seconds'): time.sleep(obj.wait_seconds) if hasattr(obj, 'wait_for_element_with_text'): diff --git a/tools/telemetry/telemetry/page_runner.py b/tools/telemetry/telemetry/page_runner.py index ace1ecd..09508b7 100644 --- a/tools/telemetry/telemetry/page_runner.py +++ b/tools/telemetry/telemetry/page_runner.py @@ -155,7 +155,7 @@ http://goto/read-src-internal, or create a new archive using record_wpr. page_state = PageState() try: - did_prepare = self._PreparePage(page, tab, page_state, results) + did_prepare = self._PreparePage(page, tab, page_state, test, results) except util.TimeoutException, ex: logging.warning('Timed out waiting for reply on %s. This is unusual.', page.url) @@ -245,7 +245,7 @@ http://goto/read-src-internal, or create a new archive using record_wpr. trace_file.write(trace) logging.info('Trace saved.') - def _PreparePage(self, page, tab, page_state, results): + def _PreparePage(self, page, tab, page_state, test, results): parsed_url = urlparse.urlparse(page.url) if parsed_url[0] == 'file': dirname, filename = page.url_base_dir_and_file @@ -264,13 +264,16 @@ http://goto/read-src-internal, or create a new archive using record_wpr. results.AddFailure(page, msg, "") return False + test.WillNavigateToPage(page, tab) tab.page.Navigate(target_side_url) + test.DidNavigateToPage(page, tab) # Wait for unpredictable redirects. if page.wait_time_after_navigate: time.sleep(page.wait_time_after_navigate) page.WaitToLoad(tab, 60) tab.WaitForDocumentReadyStateToBeInteractiveOrBetter() + return True def _CleanUpPage(self, page, tab, page_state): # pylint: disable=R0201 diff --git a/tools/telemetry/telemetry/page_test.py b/tools/telemetry/telemetry/page_test.py index 0aaf230..eb4938f 100644 --- a/tools/telemetry/telemetry/page_test.py +++ b/tools/telemetry/telemetry/page_test.py @@ -65,6 +65,15 @@ class PageTest(object): """Override to customize if the test can be ran for the given page.""" return True + def WillNavigateToPage(self, page, tab): + """Override to do operations before the page is navigated.""" + pass + + def DidNavigateToPage(self, page, tab): + """Override to do operations right after the page is navigated, but before + any waiting for completion has occurred.""" + pass + def WillRunInteraction(self, page, tab): """Override to do operations before running the interaction on the page.""" pass |