Skip to content

Instantly share code, notes, and snippets.

@jerch
Created January 4, 2019 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jerch/07ea5e2dfc0548df63a9113d6d721aee to your computer and use it in GitHub Desktop.
Save jerch/07ea5e2dfc0548df63a9113d6d721aee to your computer and use it in GitHub Desktop.
import { perfContext, before, ThroughputRuntimeCase } from '..';
//import * as xterm from 'xterm';
import { Terminal as TerminalType } from 'xterm/src/Terminal';
const Terminal: typeof TerminalType = require('xterm/lib/Terminal').Terminal;
const pty = require('xterm/node_modules/node-pty');
class TestTerminal extends Terminal {
writeSync(data: string) {
this.writeBuffer.push(data);
this._innerWrite();
}
}
perfContext('Terminal: ls -lR /usr/lib', () => {
let content = '';
let terminal: TestTerminal;
before(async () => {
// grab output from "ls -lR /usr/lib"
const p = pty.spawn('ls', ['--color=auto', '-lR', '/usr/lib'], {
name: 'xterm-color',
cols: 80,
rows: 25,
cwd: process.env.HOME,
env: process.env
});
let fromPty = '';
p.on('data', (data: string) => { fromPty += data; });
await new Promise(resolve => p.on('exit', () => resolve()));
// test with +50MB
while (content.length < 50000000) {
content += fromPty;
}
terminal = new TestTerminal({
cols: 80,
rows: 25,
scrollback: 1000
});
});
new ThroughputRuntimeCase('', () => {
terminal.writeSync(content);
return {payloadSize: content.length};
}, {fork: true}).showRuntime().showThroughput().showAverageRuntime().showAverageThroughput();
// }, {fork: true, forkOptions: {execArgv: ['--inspect-brk']}}).showRuntime().showThroughput().showAverageRuntime().showAverageThroughput();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment