| Index: tools/perf/benchmarks/html-parser.py
|
| diff --git a/tools/perf/benchmarks/html-parser.py b/tools/perf/benchmarks/html-parser.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e90c4bd330df39da544add5e75e661f36cdf5fb8
|
| --- /dev/null
|
| +++ b/tools/perf/benchmarks/html-parser.py
|
| @@ -0,0 +1,67 @@
|
| +# Copyright 2016 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +import os
|
| +
|
| +from core import perf_benchmark
|
| +from telemetry import page as page_module
|
| +from telemetry import story
|
| +from telemetry.page import legacy_page_test
|
| +from telemetry.value import scalar
|
| +
|
| +
|
| +class _HtmlParserMeasurement(legacy_page_test.LegacyPageTest):
|
| + def __init__(self):
|
| + super(_HtmlParserMeasurement, self).__init__()
|
| +
|
| + def _GetResult(self, tab, index):
|
| + selector = 'document.querySelectorAll("section")[%d]' % index
|
| + tab.WaitForJavaScriptExpression(
|
| + '((%s) && (%s).textContent)' % (selector, selector), 100)
|
| + extract_time_js = '(/time: (\\d+)ms/.exec(%s.textContent))[1]' % selector
|
| + return float(tab.EvaluateJavaScript(extract_time_js))
|
| +
|
| + def ValidateAndMeasurePage(self, page, tab, results):
|
| + innerHtmlTime = self._GetResult(tab, 0)
|
| + realBindingsTime = self._GetResult(tab, 1)
|
| + fakeBindingsTime = self._GetResult(tab, 2)
|
| + bindingsOverhead = max(0, realBindingsTime - fakeBindingsTime)
|
| + results.AddValue(scalar.ScalarValue(
|
| + results.current_page, 'innerHTML', 'ms', innerHtmlTime))
|
| + results.AddValue(scalar.ScalarValue(
|
| + results.current_page, 'real-bindings', 'ms', realBindingsTime))
|
| + results.AddValue(scalar.ScalarValue(
|
| + results.current_page, 'fake-bindings', 'ms', fakeBindingsTime))
|
| + results.AddValue(scalar.ScalarValue(
|
| + results.current_page, 'bindings-overhead', 'ms', bindingsOverhead))
|
| +
|
| +
|
| +class HtmlParser(perf_benchmark.PerfBenchmark):
|
| + """The benchmark parses a saved page of wikipedia.
|
| +
|
| + This is intended for real production use so authors could schedule HTML
|
| + parsing as needed, and to model data parsing into DOM.
|
| + It tests 3 things:
|
| +
|
| + 1. Parsing with the browser provided C++ innerHTML
|
| + 2. Parsing with the JS based html parser, creating real DOM.
|
| + 3. Parsing with the JS based html parser, creating *fake* DOM.
|
| + """
|
| + test = _HtmlParserMeasurement
|
| +
|
| + @classmethod
|
| + def Name(cls):
|
| + return 'html-parser'
|
| +
|
| + def CreateStorySet(self, options):
|
| + ps = story.StorySet(
|
| + archive_data_file='../page_sets/data/html-parser.json',
|
| + base_dir=os.path.dirname(os.path.abspath(__file__)),
|
| + cloud_storage_bucket=story.PARTNER_BUCKET)
|
| + ps.AddStory(page_module.Page(
|
| + 'https://1ede9c8b4261401ce30e527057727688b46ce0d9.googledrive.com/'
|
| + 'host/0B4QUVw-AB8wPVXpWVzZ5T1hObGc/dom_create.html',
|
| + ps, ps.base_dir, name='html-parser',
|
| + make_javascript_deterministic=False))
|
| + return ps
|
|
|