@@ -705,13 +705,13 @@ function loadTest(term: Terminal, addons: AddonCollection): void {
705705 term . write ( '' , ( ) => {
706706 const time = Math . round ( performance . now ( ) - start ) ;
707707 const mbs = ( ( byteCount / 1024 ) * ( 1 / ( time / 1000 ) ) ) . toFixed ( 2 ) ;
708- term . write ( `\n\r\nWrote ${ byteCount } kB in ${ time } ms (${ mbs } MB /s) using the (${ rendererName } renderer)` ) ;
708+ term . write ( `\n\r\nWrote ${ byteCount } KiB in ${ time } ms (${ mbs } MiB /s) using the (${ rendererName } renderer)` ) ;
709709 // Send ^C to get a new prompt
710710 ( term as any ) . _core . _onData . fire ( '\x03' ) ;
711711 } ) ;
712712}
713713
714- function loadTestLongLines ( term : Terminal , addons : AddonCollection ) : void {
714+ async function loadTestLongLines ( term : Terminal , addons : AddonCollection ) : Promise < void > {
715715 const rendererName = addons . webgl . instance ? 'webgl' : 'dom' ;
716716 const testData = [ ] ;
717717 let byteCount = 0 ;
@@ -729,16 +729,23 @@ function loadTestLongLines(term: Terminal, addons: AddonCollection): void {
729729 testData . push ( data ) ;
730730 }
731731 const start = performance . now ( ) ;
732- for ( let i = 0 ; i < 1024 * 50 ; i ++ ) {
732+ for ( let i = 0 ; i < 1024 ; i ++ ) {
733733 for ( const d of testData ) {
734- term . write ( d ) ;
734+ try {
735+ term . write ( d ) ;
736+ } catch {
737+ // Flush events when cap is hit and try again(workaround for not having flow control in
738+ // demo)
739+ await new Promise < void > ( r => term . write ( '' , ( ) => r ( ) ) ) ;
740+ term . write ( d ) ;
741+ }
735742 }
736743 }
737744 // Wait for all data to be parsed before evaluating time
738745 term . write ( '' , ( ) => {
739746 const time = Math . round ( performance . now ( ) - start ) ;
740747 const mbs = ( ( byteCount / 1024 ) * ( 1 / ( time / 1000 ) ) ) . toFixed ( 2 ) ;
741- term . write ( `\n\r\nWrote ${ byteCount } kB in ${ time } ms (${ mbs } MB /s) using the (${ rendererName } renderer)` ) ;
748+ term . write ( `\n\r\nWrote ${ byteCount } KiB in ${ time } ms (${ mbs } MiB /s) using the (${ rendererName } renderer)` ) ;
742749 // Send ^C to get a new prompt
743750 ( term as any ) . _core . _onData . fire ( '\x03' ) ;
744751 } ) ;
0 commit comments