Mojo C++ bindings: better log message for serialization warnings.
[chromium-blink-merge.git] / tools / perf / benchmarks / indexeddb_perf.py
blob3bc8cc8b1f6504479560e9c75c5160a6858f9c10
1 # Copyright 2013 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.
5 """Runs Chromium's IndexedDB performance test. These test:
7 Databases:
8 create/delete
9 Keys:
10 create/delete
11 Indexes:
12 create/delete
13 Data access:
14 Random read/write
15 Read cache
16 Cursors:
17 Read & random writes
18 Walking multiple
19 Seeking.
20 """
22 import json
23 import os
25 from metrics import memory
26 from metrics import power
27 from metrics import v8_object_stats
28 from telemetry import benchmark
29 from telemetry.core import util
30 from telemetry.page import page_set
31 from telemetry.page import page_test
32 from telemetry.value import scalar
34 _V8_COUNTER_NAMES = [
35 'V8.OsMemoryAllocated',
38 class _IndexedDbMeasurement(page_test.PageTest):
39 def __init__(self, *args, **kwargs):
40 super(_IndexedDbMeasurement, self).__init__(*args, **kwargs)
41 self._memory_metric = None
42 self._power_metric = None
43 self._v8_object_stats_metric = None
45 def WillStartBrowser(self, browser):
46 """Initialize metrics once right before the browser has been launched."""
47 self._power_metric = power.PowerMetric(browser)
49 def DidStartBrowser(self, browser):
50 """Initialize metrics once right after the browser has been launched."""
51 self._memory_metric = memory.MemoryMetric(browser)
52 self._v8_object_stats_metric = (
53 v8_object_stats.V8ObjectStatsMetric(_V8_COUNTER_NAMES))
55 def DidNavigateToPage(self, page, tab):
56 self._memory_metric.Start(page, tab)
57 self._power_metric.Start(page, tab)
58 self._v8_object_stats_metric.Start(page, tab)
60 def ValidateAndMeasurePage(self, page, tab, results):
61 tab.WaitForDocumentReadyStateToBeComplete()
62 tab.WaitForJavaScriptExpression(
63 'window.document.cookie.indexOf("__done=1") >= 0', 600)
65 self._power_metric.Stop(page, tab)
66 self._memory_metric.Stop(page, tab)
67 self._v8_object_stats_metric.Stop(page, tab)
69 self._memory_metric.AddResults(tab, results)
70 self._power_metric.AddResults(tab, results)
71 self._v8_object_stats_metric.AddResults(tab, results)
73 js_get_results = "JSON.stringify(automation.getResults());"
74 result_dict = json.loads(tab.EvaluateJavaScript(js_get_results))
75 total = 0.0
76 for key in result_dict:
77 if key == 'OverallTestDuration':
78 continue
79 msec = float(result_dict[key])
80 results.AddValue(scalar.ScalarValue(
81 results.current_page, key, 'ms', msec, important=False))
83 total += msec
84 results.AddValue(scalar.ScalarValue(
85 results.current_page, 'Total Perf', 'ms', total))
88 def CustomizeBrowserOptions(self, options):
89 memory.MemoryMetric.CustomizeBrowserOptions(options)
90 power.PowerMetric.CustomizeBrowserOptions(options)
91 v8_object_stats.V8ObjectStatsMetric.CustomizeBrowserOptions(options)
93 class IndexedDb(benchmark.Benchmark):
94 """Chromium's IndexedDB Performance tests."""
95 test = _IndexedDbMeasurement
97 def CreatePageSet(self, options):
98 indexeddb_dir = os.path.join(util.GetChromiumSrcDir(), 'chrome', 'test',
99 'data', 'indexeddb')
100 ps = page_set.PageSet(file_path=indexeddb_dir)
101 ps.AddPageWithDefaultRunNavigate('file://perf_test.html')
102 return ps