Skip to content

Commit

Permalink
more timings (#578)
Browse files Browse the repository at this point in the history
* more timings

* Remove router timing
yoshuawuyts authored and tornqvist committed Jun 12, 2019
1 parent d62691f commit b373c7e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ module.exports = Choo
var HISTORY_OBJECT = {}

function Choo (opts) {
var timing = nanotiming('choo.constructor')
if (!(this instanceof Choo)) return new Choo(opts)
opts = opts || {}

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

Choo.prototype.route = function (route, handler) {
var routeTiming = nanotiming("choo.route('" + route + "')")
assert.equal(typeof route, 'string', 'choo.route: route should be type string')
assert.equal(typeof handler, 'function', 'choo.handler: route should be type function')
this.router.on(route, handler)
routeTiming()
}

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

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

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

startTiming()
return this._tree
}

Choo.prototype.mount = function mount (selector) {
var mountTiming = nanotiming("choo.mount('" + selector + "')")
if (typeof window !== 'object') {
assert.ok(typeof selector === 'string', 'choo.mount: selector should be type String')
this.selector = selector
mountTiming()
return this
}

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

renderTiming()
})
mountTiming()
}

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

0 comments on commit b373c7e

Please sign in to comment.