Skip to content

Commit b373c7e

Browse files
yoshuawuytstornqvist
authored andcommitted
more timings (#578)
* more timings * Remove router timing
1 parent d62691f commit b373c7e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module.exports = Choo
1616
var HISTORY_OBJECT = {}
1717

1818
function Choo (opts) {
19+
var timing = nanotiming('choo.constructor')
1920
if (!(this instanceof Choo)) return new Choo(opts)
2021
opts = opts || {}
2122

@@ -70,12 +71,15 @@ function Choo (opts) {
7071
self.state.title = title
7172
if (self._hasWindow) document.title = title
7273
})
74+
timing()
7375
}
7476

7577
Choo.prototype.route = function (route, handler) {
78+
var routeTiming = nanotiming("choo.route('" + route + "')")
7679
assert.equal(typeof route, 'string', 'choo.route: route should be type string')
7780
assert.equal(typeof handler, 'function', 'choo.handler: route should be type function')
7881
this.router.on(route, handler)
82+
routeTiming()
7983
}
8084

8185
Choo.prototype.use = function (cb) {
@@ -92,6 +96,7 @@ Choo.prototype.use = function (cb) {
9296

9397
Choo.prototype.start = function () {
9498
assert.equal(typeof window, 'object', 'choo.start: window was not found. .start() must be called in a browser, use .toString() if running in Node')
99+
var startTiming = nanotiming('choo.start')
95100

96101
var self = this
97102
if (this._historyEnabled) {
@@ -166,13 +171,16 @@ Choo.prototype.start = function () {
166171
self._loaded = true
167172
})
168173

174+
startTiming()
169175
return this._tree
170176
}
171177

172178
Choo.prototype.mount = function mount (selector) {
179+
var mountTiming = nanotiming("choo.mount('" + selector + "')")
173180
if (typeof window !== 'object') {
174181
assert.ok(typeof selector === 'string', 'choo.mount: selector should be type String')
175182
this.selector = selector
183+
mountTiming()
176184
return this
177185
}
178186

@@ -200,6 +208,7 @@ Choo.prototype.mount = function mount (selector) {
200208

201209
renderTiming()
202210
})
211+
mountTiming()
203212
}
204213

205214
Choo.prototype.toString = function (location, state) {

0 commit comments

Comments
 (0)