Skip to content

Instantly share code, notes, and snippets.

@yyx990803
Last active February 17, 2017 00:52
Show Gist options
  • Save yyx990803/7cfec746bb8cd6ae05e72f30104c0d51 to your computer and use it in GitHub Desktop.
Save yyx990803/7cfec746bb8cd6ae05e72f30104c0d51 to your computer and use it in GitHub Desktop.
const marky = require('marky')
const render = Vue.prototype._render
const update = Vue.prototype._update
const camelize = str => str && Vue.util.camelize(str)
function getName (vm) {
if (!vm.$parent) return 'root'
return (
camelize(vm.$options.name) ||
camelize(vm.$options._componentTag) ||
'anonymous'
) + `-${vm._uid}`
}
Vue.prototype._render = function () {
const id = `render:${getName(this)}`
marky.mark(id)
const vnode = render.apply(this, arguments)
marky.stop(id)
return vnode
}
Vue.prototype._update = function () {
const id = `patch:${getName(this)}`
marky.mark(id)
update.apply(this, arguments)
marky.stop(id)
}
@crswll
Copy link

crswll commented Jan 12, 2017

lol marky.mark().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment