shorter ssr bench output

This commit is contained in:
Evan You 2016-12-02 23:45:59 -05:00
parent ea7c353902
commit e4a49b7432
1 changed files with 11 additions and 8 deletions

View File

@ -1,3 +1,5 @@
/* eslint-disable no-unused-vars */
'use strict' 'use strict'
const Vue = require('../../dist/vue.runtime.common.js') const Vue = require('../../dist/vue.runtime.common.js')
@ -7,20 +9,21 @@ const gridComponent = require('./common.js')
console.log('--- renderToStream --- ') console.log('--- renderToStream --- ')
const self = (global || root) const self = (global || root)
self.s = self.performance.now() const s = self.performance.now()
const stream = renderToStream(new Vue(gridComponent)) const stream = renderToStream(new Vue(gridComponent))
let str = '' let str = ''
const stats = [] let first
let complete
stream.once('data', () => {
first = self.performance.now() - s
})
stream.on('data', chunk => { stream.on('data', chunk => {
str += chunk str += chunk
stats.push(self.performance.now())
}) })
stream.on('end', () => { stream.on('end', () => {
stats.push(self.performance.now()) complete = self.performance.now() - s
stats.forEach((val, index) => { console.log(`first chunk: ${first.toFixed(2)}ms`)
const type = index !== stats.length - 1 ? 'Chunk' : 'Complete' console.log(`complete: ${complete.toFixed(2)}ms`)
console.log(type + ' time: ' + (val - self.s).toFixed(2) + 'ms')
})
console.log() console.log()
}) })