|
1 | 1 | /* @flow */
|
2 | 2 |
|
| 3 | +import config from '../config' |
| 4 | +import { perf } from '../util/perf' |
3 | 5 | import Watcher from '../observer/watcher'
|
4 | 6 | import { resetRefs } from '../vdom/modules/ref'
|
5 | 7 | import { createEmptyVNode } from '../vdom/vnode'
|
6 | 8 | import { observerState } from '../observer/index'
|
7 | 9 | import { updateComponentListeners } from './events'
|
8 | 10 | import { resolveSlots } from './render-helpers/resolve-slots'
|
9 |
| -import { warn, validateProp, remove, noop, emptyObject, handleError } from '../util/index' |
| 11 | + |
| 12 | +import { |
| 13 | + warn, |
| 14 | + noop, |
| 15 | + remove, |
| 16 | + handleError, |
| 17 | + emptyObject, |
| 18 | + validateProp |
| 19 | +} from '../util/index' |
10 | 20 |
|
11 | 21 | export let activeInstance: any = null
|
12 | 22 |
|
@@ -149,10 +159,31 @@ export function mountComponent (
|
149 | 159 | }
|
150 | 160 | }
|
151 | 161 | callHook(vm, 'beforeMount')
|
152 |
| - vm._watcher = new Watcher(vm, function updateComponent () { |
153 |
| - vm._update(vm._render(), hydrating) |
154 |
| - }, noop) |
| 162 | + |
| 163 | + let updateComponent |
| 164 | + if (process.env.NODE_ENV !== 'production' && config.performance && perf) { |
| 165 | + updateComponent = () => { |
| 166 | + const name = vm._name |
| 167 | + const startTag = `start ${name}` |
| 168 | + const endTag = `end ${name}` |
| 169 | + perf.mark(startTag) |
| 170 | + const vnode = vm._render() |
| 171 | + perf.mark(endTag) |
| 172 | + perf.measure(`${name} render`, startTag, endTag) |
| 173 | + perf.mark(startTag) |
| 174 | + vm._update(vnode, hydrating) |
| 175 | + perf.mark(endTag) |
| 176 | + perf.measure(`${name} patch`, startTag, endTag) |
| 177 | + } |
| 178 | + } else { |
| 179 | + updateComponent = () => { |
| 180 | + vm._update(vm._render(), hydrating) |
| 181 | + } |
| 182 | + } |
| 183 | + |
| 184 | + vm._watcher = new Watcher(vm, updateComponent, noop) |
155 | 185 | hydrating = false
|
| 186 | + |
156 | 187 | // manually mounted instance, call mounted on self
|
157 | 188 | // mounted is called for render-created child components in its inserted hook
|
158 | 189 | if (vm.$vnode == null) {
|
|
0 commit comments