more timings (#578)

* more timings

* Remove router timing
This commit is contained in:
Yoshua Wuyts
2019-06-12 13:41:09 +02:00
committed by Carl Törnqvist
parent d62691f207
commit b373c7ee06
+9
View File
@@ -16,6 +16,7 @@ module.exports = Choo
var HISTORY_OBJECT = {} var HISTORY_OBJECT = {}
function Choo (opts) { function Choo (opts) {
var timing = nanotiming('choo.constructor')
if (!(this instanceof Choo)) return new Choo(opts) if (!(this instanceof Choo)) return new Choo(opts)
opts = opts || {} opts = opts || {}
@@ -70,12 +71,15 @@ function Choo (opts) {
self.state.title = title self.state.title = title
if (self._hasWindow) document.title = title if (self._hasWindow) document.title = title
}) })
timing()
} }
Choo.prototype.route = function (route, handler) { 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 route, 'string', 'choo.route: route should be type string')
assert.equal(typeof handler, 'function', 'choo.handler: route should be type function') assert.equal(typeof handler, 'function', 'choo.handler: route should be type function')
this.router.on(route, handler) this.router.on(route, handler)
routeTiming()
} }
Choo.prototype.use = function (cb) { Choo.prototype.use = function (cb) {
@@ -92,6 +96,7 @@ Choo.prototype.use = function (cb) {
Choo.prototype.start = function () { 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') 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 var self = this
if (this._historyEnabled) { if (this._historyEnabled) {
@@ -166,13 +171,16 @@ Choo.prototype.start = function () {
self._loaded = true self._loaded = true
}) })
startTiming()
return this._tree return this._tree
} }
Choo.prototype.mount = function mount (selector) { Choo.prototype.mount = function mount (selector) {
var mountTiming = nanotiming("choo.mount('" + selector + "')")
if (typeof window !== 'object') { if (typeof window !== 'object') {
assert.ok(typeof selector === 'string', 'choo.mount: selector should be type String') assert.ok(typeof selector === 'string', 'choo.mount: selector should be type String')
this.selector = selector this.selector = selector
mountTiming()
return this return this
} }
@@ -200,6 +208,7 @@ Choo.prototype.mount = function mount (selector) {
renderTiming() renderTiming()
}) })
mountTiming()
} }
Choo.prototype.toString = function (location, state) { Choo.prototype.toString = function (location, state) {