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 from metrics import Metric
7 class LoadingMetric(Metric):
8 """A metric for page loading time based entirely on window.performance"""
10 def Start(self, page, tab):
11 raise NotImplementedError()
13 def Stop(self, page, tab):
14 raise NotImplementedError()
16 def AddResults(self, tab, results):
17 load_timings = tab.EvaluateJavaScript('window.performance.timing')
19 float(load_timings['loadEventStart']) -
20 load_timings['navigationStart'])
21 dom_content_loaded_time_ms = (
22 float(load_timings['domContentLoadedEventStart']) -
23 load_timings['navigationStart'])
24 results.Add('load_time', 'ms', load_time_ms)
25 results.Add('dom_content_loaded_time', 'ms',
26 dom_content_loaded_time_ms)