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

Side by Side Diff: third_party/google_input_tools/src/chrome/os/inputview/perftracker.js

Issue 701603002: Update to google-input-tools version 1.0.5.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
OLDNEW
(Empty)
1 // Copyright 2014 The ChromeOS IME Authors. All Rights Reserved.
2 // limitations under the License.
3 // See the License for the specific language governing permissions and
4 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5 // distributed under the License is distributed on an "AS-IS" BASIS,
6 // Unless required by applicable law or agreed to in writing, software
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // You may obtain a copy of the License at
11 // you may not use this file except in compliance with the License.
12 // Licensed under the Apache License, Version 2.0 (the "License");
13 //
14 goog.provide('i18n.input.chrome.inputview.PerfTracker');
15
16 goog.require('i18n.input.chrome.Statistics');
17
18
19 goog.scope(function() {
20
21
22
23 /**
24 * The tracker for the performance.
25 *
26 * @param {PerfTracker.TickName} htmlLoadedTickName .
27 * @constructor
28 */
29 i18n.input.chrome.inputview.PerfTracker = function(
30 htmlLoadedTickName) {
31 /**
32 * The time when this tracker starts.
33 *
34 * @private {number}
35 */
36 this.startInMs_ = new Date().getTime();
37
38 this.tick(htmlLoadedTickName,
39 window['InputViewPageStartLoading']);
40 };
41 var PerfTracker = i18n.input.chrome.inputview.PerfTracker;
42
43
44 /** @private {boolean} */
45 PerfTracker.prototype.stopped_ = false;
46
47
48 /**
49 * The name of the tick.
50 *
51 * @enum {string}
52 */
53 PerfTracker.TickName = {
54 BACKGROUND_HTML_LOADED: 'BackgroundHtmlLoaded',
55 NACL_LOADED: 'NaclLoaded',
56 BACKGROUND_SETTINGS_FETCHED: 'BackgroundSettingsFetched',
57 HTML_LOADED: 'HtmlLoaded',
58 KEYBOARD_CREATED: 'KeyboardCreated',
59 KEYBOARD_SHOWN: 'KeyboardShown',
60 KEYSET_LOADED: 'KeysetLoaded',
61 LAYOUT_LOADED: 'LayoutLoaded'
62 };
63
64
65 /**
66 * Resets this performance tracker.
67 */
68 PerfTracker.prototype.restart = function() {
69 this.startInMs_ = new Date().getTime();
70 this.stopped_ = false;
71 };
72
73
74 /**
75 * Stops the performance tracker.
76 */
77 PerfTracker.prototype.stop = function() {
78 this.stopped_ = true;
79 };
80
81
82 /**
83 * Ticks with a custom message.
84 *
85 * @param {PerfTracker.TickName} tickName .
86 * @param {number=} opt_startInMs The timestamp used as start, if not
87 * specified, use this.startInMs_.
88 */
89 PerfTracker.prototype.tick = function(tickName, opt_startInMs) {
90 if (this.stopped_) {
91 return;
92 }
93
94 var startInMs = opt_startInMs || this.startInMs_;
95 var cost = new Date().getTime() - startInMs;
96 console.log(tickName + ' - ' + cost);
97 i18n.input.chrome.Statistics.getInstance().recordLatency(
98 'InputMethod.VirtualKeyboard.InitLatency.' + tickName, cost);
99 };
100
101 }); // goog.scope
102
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698