Skip to content

Commit b7e535e

Browse files
committed
APC perf test
1 parent 8e12e69 commit b7e535e

1 file changed

Lines changed: 71 additions & 2 deletions

File tree

test/benchmark/EscapeSequenceParser.benchmark.ts

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import { perfContext, before, beforeEach, ThroughputRuntimeCase } from 'xterm-be
66

77
import { EscapeSequenceParser } from 'common/parser/EscapeSequenceParser';
88
import { C0, C1 } from 'common/data/EscapeSequences';
9-
import { IDcsHandler, IOscHandler, IParams } from 'common/parser/Types';
9+
import { IDcsHandler, IOscHandler, IApcHandler, IParams } from 'common/parser/Types';
1010
import { OscHandler } from 'common/parser/OscParser';
11-
import { DcsHandler } from '../../out/common/parser/DcsParser';
11+
import { DcsHandler } from 'common/parser/DcsParser';
12+
import { ApcHandler } from 'common/parser/ApcParser';
1213

1314
const SIZE = 5000000;
1415

@@ -32,6 +33,12 @@ class FastOscHandler implements IOscHandler {
3233
public end(success: boolean): boolean { return true; }
3334
}
3435

36+
class FastApcHandler implements IApcHandler {
37+
public start(): void {}
38+
public put(data: Uint32Array, start: number, end: number): void {}
39+
public end(success: boolean): boolean { return true; }
40+
}
41+
3542

3643
perfContext('Parser throughput - 50MB data', () => {
3744
let parsed: Uint32Array;
@@ -108,6 +115,8 @@ perfContext('Parser throughput - 50MB data', () => {
108115
parser.registerEscHandler({ intermediates: '%', final: 'G' }, () => true);
109116
parser.registerDcsHandler({ final: 'p' }, new DcsHandler(data => true));
110117
parser.registerDcsHandler({ final: 'q' }, new FastDcsHandler());
118+
parser.registerApcHandler({ final: 'X' }, new ApcHandler(data => true));
119+
parser.registerApcHandler({ final: 'Y' }, new FastApcHandler());
111120
});
112121

113122
perfContext('PRINT - a', () => {
@@ -349,4 +358,64 @@ perfContext('Parser throughput - 50MB data', () => {
349358
return { payloadSize: parsed.length };
350359
}, { fork: true }).showAverageThroughput();
351360
});
361+
362+
perfContext('APC string interface (short seq)', () => {
363+
before(() => {
364+
const data = '\x1b_Xhi\x1b\\\x1b_Xhi\x1b\\\x1b_Xhi\x1b\\\x1b_Xhi\x1b\\\x1b_Xhi\x1b\\';
365+
let content = '';
366+
while (content.length < SIZE) {
367+
content += data;
368+
}
369+
parsed = toUtf32(content);
370+
});
371+
new ThroughputRuntimeCase('', async () => {
372+
parser.parse(parsed, parsed.length);
373+
return { payloadSize: parsed.length };
374+
}, { fork: true }).showAverageThroughput();
375+
});
376+
377+
perfContext('APC string interface (long seq)', () => {
378+
before(() => {
379+
const data = '\x1b_XLorem ipsum dolor sit amet, consetetur sadipscing elitr.\x1b\\';
380+
let content = '';
381+
while (content.length < SIZE) {
382+
content += data;
383+
}
384+
parsed = toUtf32(content);
385+
});
386+
new ThroughputRuntimeCase('', async () => {
387+
parser.parse(parsed, parsed.length);
388+
return { payloadSize: parsed.length };
389+
}, { fork: true }).showAverageThroughput();
390+
});
391+
392+
perfContext('APC class interface (short seq)', () => {
393+
before(() => {
394+
const data = '\x1b_Yhi\x1b\\\x1b_Yhi\x1b\\\x1b_Yhi\x1b\\\x1b_Yhi\x1b\\\x1b_Yhi\x1b\\';
395+
let content = '';
396+
while (content.length < SIZE) {
397+
content += data;
398+
}
399+
parsed = toUtf32(content);
400+
});
401+
new ThroughputRuntimeCase('', async () => {
402+
parser.parse(parsed, parsed.length);
403+
return { payloadSize: parsed.length };
404+
}, { fork: true }).showAverageThroughput();
405+
});
406+
407+
perfContext('APC class interface (long seq)', () => {
408+
before(() => {
409+
const data = '\x1b_YLorem ipsum dolor sit amet, consetetur sadipscing elitr.\x1b\\';
410+
let content = '';
411+
while (content.length < SIZE) {
412+
content += data;
413+
}
414+
parsed = toUtf32(content);
415+
});
416+
new ThroughputRuntimeCase('', async () => {
417+
parser.parse(parsed, parsed.length);
418+
return { payloadSize: parsed.length };
419+
}, { fork: true }).showAverageThroughput();
420+
});
352421
});

0 commit comments

Comments
 (0)