1. add 8 secs timeout for SerializeAddon API test
2. move demo page's addons control panel into a single div
3. remove unnecessary config in demo page
4. remove v8-profiler-node8 dependency
5. remove duplicate css option
This commit is contained in:
javacs3
2019-11-28 22:22:04 +08:00
parent 3969eb9382
commit 903d75e6d3
7 changed files with 20 additions and 44 deletions
@@ -16,6 +16,7 @@ const height = 600;
describe('SerializeAddon', () => {
before(async function (): Promise<any> {
this.timeout(8 * 1000);
browser = await puppeteer.launch({
headless: process.argv.indexOf('--headless') !== -1,
args: [`--window-size=${width},${height}`]
-2
View File
@@ -391,10 +391,8 @@ function updateTerminalSize(): void {
function serializeButtonHandler(): void {
const output = addons.serialize.instance.serialize();
const outputString = JSON.stringify(output);
console.log('serialize output', outputString);
document.getElementById('serialize-output').innerText = outputString;
if ((document.getElementById('write-to-terminal') as HTMLInputElement).checked) {
term.reset();
term.write(output);
+15 -16
View File
@@ -11,22 +11,6 @@
<body>
<h1 style="color: #2D2E2C">xterm.js: A terminal for the <em style="color: #5DA5D5">web</em></h1>
<div id="terminal-container"></div>
<div>
<h3>Actions</h3>
<p>
<label>Find next <input id="find-next"/></label>
<label>Find previous <input id="find-previous"/></label>
<label>Use regex<input type="checkbox" id="regex"/></label>
<label>Case sensitive<input type="checkbox" id="case-sensitive"/></label>
<label>Whole word<input type="checkbox" id="whole-word"/></label>
</p>
<div>
<h3>SerializeAddon</h3>
<button id="serialize">Serialize the content of terminal</button>
<label><input type="checkbox" id="write-to-terminal">Write back to terminal</label>
<div><pre id="serialize-output"></pre></div>
</div>
</div>
<div>
<h3>Options</h3>
<p>These options can be set in the <code>Terminal</code> constructor or using the <code>Terminal.setOption</code> function.</p>
@@ -36,6 +20,21 @@
<h3>Addons</h3>
<p>Addons can be loaded and unloaded on a particular terminal to extend its functionality.</p>
<div id="addons-container"></div>
<h3>Addons Control</h3>
<h4>SearchAddon</h4>
<p>
<label>Find next <input id="find-next"/></label>
<label>Find previous <input id="find-previous"/></label>
<label>Use regex<input type="checkbox" id="regex"/></label>
<label>Case sensitive<input type="checkbox" id="case-sensitive"/></label>
<label>Whole word<input type="checkbox" id="whole-word"/></label>
</p>
<h4>SerializeAddon</h4>
<p>
<button id="serialize">Serialize the content of terminal</button>
<label><input type="checkbox" id="write-to-terminal">Write back to terminal</label>
<div><pre id="serialize-output"></pre></div>
</p>
</div>
<div>
<h3>Style</h3>
+1 -2
View File
@@ -48,8 +48,7 @@ const clientConfig = {
extensions: [ '.tsx', '.ts', '.js' ],
alias: {
common: path.resolve('./out/common'),
browser: path.resolve('./out/browser'),
xterm$: path.resolve('./out/public/Terminal.js')
browser: path.resolve('./out/browser')
}
},
output: {
-1
View File
@@ -40,5 +40,4 @@ pre {
word-break: break-all;
word-wrap: break-word;
white-space: pre-wrap;
word-wrap: break-word;
}
-1
View File
@@ -55,7 +55,6 @@
"tslint-consistent-codestyle": "^1.13.0",
"typescript": "3.7",
"utf8": "^3.0.0",
"v8-profiler-node8": "^6.1.1",
"webpack": "^4.35.3",
"webpack-cli": "^3.1.0",
"ws": "^7.0.0",
+3 -22
View File
@@ -3,23 +3,16 @@
* @license MIT
*/
import { perfContext, before, after, ThroughputRuntimeCase } from 'xterm-benchmark';
import { perfContext, before, ThroughputRuntimeCase } from 'xterm-benchmark';
import * as fs from 'fs'
import { spawn } from 'node-pty';
import * as profiler from 'v8-profiler-node8';
import { Utf8ToUtf32, stringFromCodePoint } from 'common/input/TextDecoder';
import { Terminal } from 'public/Terminal';
import { SerializeAddon } from 'addons/xterm-addon-serialize/src/SerializeAddon';
class TestTerminal extends Terminal {
writeSync(data: string): void {
(<any>this)._core.writeBuffer.push(data);
(<any>this)._core._innerWrite();
}
writeSyncUtf8(data: Uint8Array): void {
(<any>this)._core.writeBufferUtf8.push(data);
(<any>this)._core._innerWriteUtf8();
(<any>this)._core.writeSync(data);
}
}
@@ -59,24 +52,12 @@ perfContext('Terminal: sh -c "dd if=/dev/random count=40 bs=1k | hexdump | lolca
perfContext('serialize', () => {
let terminal: TestTerminal;
let serializeAddon = new SerializeAddon();
const serializeAddon = new SerializeAddon();
before(() => {
terminal = new TestTerminal({ cols: 80, rows: 25, scrollback: 5000 });
serializeAddon.activate(terminal);
terminal.writeSync(content);
profiler.startProfiling();
});
after(() => {
const p1 = profiler.stopProfiling();
p1.export((err, res) => {
if (err) {
console.error(err);
return;
}
console.log(p1.getHeader());
fs.writeFileSync('serialize-profile.cpuprofile', res);
})
})
new ThroughputRuntimeCase('', () => {
return { payloadSize: serializeAddon.serialize().length };
}, { fork: false }).showAverageThroughput();