2016-12-03 12:45:59 +08:00
|
|
|
/* eslint-disable no-unused-vars */
|
|
|
|
|
2016-05-17 04:29:08 +08:00
|
|
|
'use strict'
|
|
|
|
|
2017-03-17 12:09:12 +08:00
|
|
|
process.env.NODE_ENV = 'production'
|
|
|
|
|
2016-11-17 05:41:44 +08:00
|
|
|
const Vue = require('../../dist/vue.runtime.common.js')
|
2016-06-25 12:05:39 +08:00
|
|
|
const createRenderer = require('../../packages/vue-server-renderer').createRenderer
|
2016-05-17 04:29:08 +08:00
|
|
|
const renderToStream = createRenderer().renderToStream
|
|
|
|
const gridComponent = require('./common.js')
|
|
|
|
|
|
|
|
console.log('--- renderToStream --- ')
|
|
|
|
const self = (global || root)
|
2016-12-03 12:45:59 +08:00
|
|
|
const s = self.performance.now()
|
2016-05-17 04:29:08 +08:00
|
|
|
|
|
|
|
const stream = renderToStream(new Vue(gridComponent))
|
|
|
|
let str = ''
|
2016-12-03 12:45:59 +08:00
|
|
|
let first
|
|
|
|
let complete
|
|
|
|
stream.once('data', () => {
|
|
|
|
first = self.performance.now() - s
|
|
|
|
})
|
2016-05-17 04:29:08 +08:00
|
|
|
stream.on('data', chunk => {
|
|
|
|
str += chunk
|
|
|
|
})
|
|
|
|
stream.on('end', () => {
|
2016-12-03 12:45:59 +08:00
|
|
|
complete = self.performance.now() - s
|
|
|
|
console.log(`first chunk: ${first.toFixed(2)}ms`)
|
|
|
|
console.log(`complete: ${complete.toFixed(2)}ms`)
|
2016-05-17 04:29:08 +08:00
|
|
|
console.log()
|
|
|
|
})
|