Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Side by Side Diff: tools/perf/benchmarks/html-parser.py

Issue 2119413003: Add HTML parsing benchmark. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: upload wpr Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/perf/page_sets/data/html-parser.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2016 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.
4
5 import os
6
7 from core import perf_benchmark
8 from telemetry import page as page_module
9 from telemetry import story
10 from telemetry.page import legacy_page_test
11 from telemetry.value import scalar
12
13
14 class _HtmlParserMeasurement(legacy_page_test.LegacyPageTest):
15 def __init__(self):
16 super(_HtmlParserMeasurement, self).__init__()
17
18 def _GetResult(self, tab, index):
19 selector = 'document.querySelectorAll("section")[%d]' % index
20 tab.WaitForJavaScriptExpression(
21 '((%s) && (%s).textContent)' % (selector, selector), 100)
22 extract_time_js = '(/time: (\\d+)ms/.exec(%s.textContent))[1]' % selector
23 return float(tab.EvaluateJavaScript(extract_time_js))
24
25 def ValidateAndMeasurePage(self, page, tab, results):
26 innerHtmlTime = self._GetResult(tab, 0)
27 realBindingsTime = self._GetResult(tab, 1)
28 fakeBindingsTime = self._GetResult(tab, 2)
29 bindingsOverhead = max(0, realBindingsTime - fakeBindingsTime)
30 results.AddValue(scalar.ScalarValue(
31 results.current_page, 'innerHTML', 'ms', innerHtmlTime))
32 results.AddValue(scalar.ScalarValue(
33 results.current_page, 'real-bindings', 'ms', realBindingsTime))
34 results.AddValue(scalar.ScalarValue(
35 results.current_page, 'fake-bindings', 'ms', fakeBindingsTime))
36 results.AddValue(scalar.ScalarValue(
37 results.current_page, 'bindings-overhead', 'ms', bindingsOverhead))
38
39
40 class HtmlParser(perf_benchmark.PerfBenchmark):
41 """The benchmark parses a saved page of wikipedia.
42
43 This is intended for real production use so authors could schedule HTML
44 parsing as needed, and to model data parsing into DOM.
45 It tests 3 things:
46
47 1. Parsing with the browser provided C++ innerHTML
48 2. Parsing with the JS based html parser, creating real DOM.
49 3. Parsing with the JS based html parser, creating *fake* DOM.
50 """
51 test = _HtmlParserMeasurement
52
53 @classmethod
54 def Name(cls):
55 return 'html-parser'
56
57 def CreateStorySet(self, options):
58 ps = story.StorySet(
59 archive_data_file='../page_sets/data/html-parser.json',
60 base_dir=os.path.dirname(os.path.abspath(__file__)),
61 cloud_storage_bucket=story.PARTNER_BUCKET)
62 ps.AddStory(page_module.Page(
63 'https://1ede9c8b4261401ce30e527057727688b46ce0d9.googledrive.com/'
64 'host/0B4QUVw-AB8wPVXpWVzZ5T1hObGc/dom_create.html',
65 ps, ps.base_dir, name='html-parser',
66 make_javascript_deterministic=False))
67 return ps
OLDNEW
« no previous file with comments | « no previous file | tools/perf/page_sets/data/html-parser.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698