@@ -137,7 +137,7 @@ export class WriteBuffer extends Disposable {
137137 * effectively lowering the redrawing needs, schematically:
138138 *
139139 * macroTask _innerWrite:
140- * if (Date .now() - (lastTime | 0) < WRITE_TIMEOUT_MS):
140+ * if (performance .now() - (lastTime | 0) < WRITE_TIMEOUT_MS):
141141 * schedule microTask _innerWrite(lastTime)
142142 * else:
143143 * schedule macroTask _innerWrite(0)
@@ -158,7 +158,7 @@ export class WriteBuffer extends Disposable {
158158 * Note, for pure sync code `lastTime` and `promiseResult` have no meaning.
159159 */
160160 protected _innerWrite ( lastTime : number = 0 , promiseResult : boolean = true ) : void {
161- const startTime = lastTime || Date . now ( ) ;
161+ const startTime = lastTime || performance . now ( ) ;
162162 while ( this . _writeBuffer . length > this . _bufferOffset ) {
163163 const data = this . _writeBuffer [ this . _bufferOffset ] ;
164164 const result = this . _action ( data , promiseResult ) ;
@@ -186,7 +186,7 @@ export class WriteBuffer extends Disposable {
186186 * responsibility to slice hard work), but we can at least schedule a screen update as we
187187 * gain control.
188188 */
189- const continuation : ( r : boolean ) => void = ( r : boolean ) => Date . now ( ) - startTime >= WRITE_TIMEOUT_MS
189+ const continuation : ( r : boolean ) => void = ( r : boolean ) => performance . now ( ) - startTime >= WRITE_TIMEOUT_MS
190190 ? setTimeout ( ( ) => this . _innerWrite ( 0 , r ) )
191191 : this . _innerWrite ( startTime , r ) ;
192192
@@ -202,7 +202,8 @@ export class WriteBuffer extends Disposable {
202202 * throughput by eval'ing `startTime` upfront pulling at least one more chunk into the
203203 * current microtask queue (executed before setTimeout).
204204 */
205- // const continuation: (r: boolean) => void = Date.now() - startTime >= WRITE_TIMEOUT_MS
205+ // const continuation: (r: boolean) => void = performance.now() - startTime >=
206+ // WRITE_TIMEOUT_MS
206207 // ? r => setTimeout(() => this._innerWrite(0, r))
207208 // : r => this._innerWrite(startTime, r);
208209
@@ -222,7 +223,7 @@ export class WriteBuffer extends Disposable {
222223 this . _bufferOffset ++ ;
223224 this . _pendingData -= data . length ;
224225
225- if ( Date . now ( ) - startTime >= WRITE_TIMEOUT_MS ) {
226+ if ( performance . now ( ) - startTime >= WRITE_TIMEOUT_MS ) {
226227 break ;
227228 }
228229 }
0 commit comments