Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 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 /** | |
| 6 * @fileoverview Utility methods for accessing chrome.metricsPrivate API. | |
| 7 * | |
| 8 * To be included as a first script in main.html | |
| 9 */ | |
| 10 | |
| 11 var metrics = {}; | |
|
arv (Not doing code reviews)
2011/12/19 22:57:14
I'm a bit confused. I thought this would do a chro
yoshiki
2011/12/20 15:18:25
You're right. I intended to add recording histogra
| |
| 12 | |
| 13 metrics.intervals = {}; | |
| 14 | |
| 15 metrics.startInterval = function(name) { | |
| 16 metrics.intervals[name] = Date.now(); | |
| 17 }; | |
| 18 | |
| 19 metrics.startInterval('Load.Total'); | |
| 20 metrics.startInterval('Load.Script'); | |
| 21 | |
| 22 metrics.convertName_ = function(name) { | |
| 23 return 'TaskManager.' + name; | |
| 24 }; | |
| 25 | |
| 26 metrics.decorate = function(name) { | |
| 27 this[name] = function() { | |
| 28 var args = Array.apply(null, arguments); | |
|
arv (Not doing code reviews)
2011/12/19 22:57:14
This is error prone. If argument.length == 1 and a
| |
| 29 args[0] = metrics.convertName_(args[0]); | |
| 30 | |
| 31 // TODO(yoshiki): Enables the recoading metrixes of loading times. | |
|
arv (Not doing code reviews)
2011/12/19 22:57:14
Is "metrixes" a real word?
| |
| 32 // chrome.metricsPrivate[name].apply(chrome.metricsPrivate, args); | |
|
arv (Not doing code reviews)
2011/12/19 22:57:14
Look into chrome.send. We already have a chrome se
| |
| 33 | |
| 34 // Outputs log to Console in inspector if the flag is enabled. | |
| 35 if (localStorage.logMetrics) { | |
|
arv (Not doing code reviews)
2011/12/19 22:57:14
no {} here
| |
| 36 console.log('chrome.metricsPrivate.' + name, args); | |
| 37 } | |
| 38 } | |
| 39 }; | |
| 40 | |
| 41 metrics.decorate('recordMediumCount'); | |
| 42 metrics.decorate('recordSmallCount'); | |
| 43 metrics.decorate('recordTime'); | |
| 44 metrics.decorate('recordUserAction'); | |
| 45 | |
| 46 metrics.recordInterval = function(name) { | |
| 47 if (name in metrics.intervals) { | |
|
James Hawkins
2011/12/19 18:35:56
Remove braces.
| |
| 48 metrics.recordTime(name, Date.now() - metrics.intervals[name]); | |
| 49 } else { | |
| 50 console.error('Unknown interval: ' + name); | |
| 51 } | |
| 52 }; | |
| OLD | NEW |