File tree 1 file changed +11
-8
lines changed
1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change
1
+ /* eslint-disable no-unused-vars */
2
+
1
3
'use strict'
2
4
3
5
const Vue = require ( '../../dist/vue.runtime.common.js' )
@@ -7,20 +9,21 @@ const gridComponent = require('./common.js')
7
9
8
10
console . log ( '--- renderToStream --- ' )
9
11
const self = ( global || root )
10
- self . s = self . performance . now ( )
12
+ const s = self . performance . now ( )
11
13
12
14
const stream = renderToStream ( new Vue ( gridComponent ) )
13
15
let str = ''
14
- const stats = [ ]
16
+ let first
17
+ let complete
18
+ stream . once ( 'data' , ( ) => {
19
+ first = self . performance . now ( ) - s
20
+ } )
15
21
stream . on ( 'data' , chunk => {
16
22
str += chunk
17
- stats . push ( self . performance . now ( ) )
18
23
} )
19
24
stream . on ( 'end' , ( ) => {
20
- stats . push ( self . performance . now ( ) )
21
- stats . forEach ( ( val , index ) => {
22
- const type = index !== stats . length - 1 ? 'Chunk' : 'Complete'
23
- console . log ( type + ' time: ' + ( val - self . s ) . toFixed ( 2 ) + 'ms' )
24
- } )
25
+ complete = self . performance . now ( ) - s
26
+ console . log ( `first chunk: ${ first . toFixed ( 2 ) } ms` )
27
+ console . log ( `complete: ${ complete . toFixed ( 2 ) } ms` )
25
28
console . log ( )
26
29
} )
You can’t perform that action at this time.
0 commit comments