vue/benchmarks/ssr/renderToStream.js

32 lines
825 B
JavaScript
Raw Normal View History

2016-12-03 12:45:59 +08:00
/* eslint-disable no-unused-vars */
'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
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()
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
})
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`)
console.log()
})