forked from xtermjs/xterm.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from jerch/clusters-patch
working perf test and API test injection
- Loading branch information
Showing
10 changed files
with
148 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
lib | ||
node_modules | ||
out-benchmark |
78 changes: 78 additions & 0 deletions
78
addons/xterm-addon-unicode-graphemes/benchmark/UnicodeGraphemeAddon.benchmark.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/** | ||
* Copyright (c) 2019 The xterm.js authors. All rights reserved. | ||
* @license MIT | ||
*/ | ||
|
||
import { perfContext, before, ThroughputRuntimeCase } from 'xterm-benchmark'; | ||
|
||
import { spawn } from 'node-pty'; | ||
import { Utf8ToUtf32, stringFromCodePoint } from 'common/input/TextDecoder'; | ||
import { Terminal } from 'browser/Terminal'; | ||
import { UnicodeGraphemeProvider } from 'UnicodeGraphemeProvider'; | ||
|
||
|
||
function fakedAddonLoad(terminal: any): void { | ||
// resembles what UnicodeGraphemesAddon.activate does under the hood | ||
terminal.unicodeService.register(new UnicodeGraphemeProvider()); | ||
terminal.unicodeService.activeVersion = '15-graphemes'; | ||
} | ||
|
||
|
||
perfContext('Terminal: ls -lR /usr/lib', () => { | ||
let content = ''; | ||
let contentUtf8: Uint8Array; | ||
|
||
before(async () => { | ||
// grab output from "ls -lR /usr" | ||
const p = spawn('ls', ['--color=auto', '-lR', '/usr/lib'], { | ||
name: 'xterm-256color', | ||
cols: 80, | ||
rows: 25, | ||
cwd: process.env.HOME, | ||
env: process.env, | ||
encoding: (null as unknown as string) // needs to be fixed in node-pty | ||
}); | ||
const chunks: Buffer[] = []; | ||
let length = 0; | ||
p.on('data', data => { | ||
chunks.push(data as unknown as Buffer); | ||
length += data.length; | ||
}); | ||
await new Promise<void>(resolve => p.on('exit', () => resolve())); | ||
contentUtf8 = Buffer.concat(chunks, length); | ||
// translate to content string | ||
const buffer = new Uint32Array(contentUtf8.length); | ||
const decoder = new Utf8ToUtf32(); | ||
const codepoints = decoder.decode(contentUtf8, buffer); | ||
for (let i = 0; i < codepoints; ++i) { | ||
content += stringFromCodePoint(buffer[i]); | ||
// peek into content to force flat repr in v8 | ||
if (!(i % 10000000)) { | ||
content[i]; | ||
} | ||
} | ||
}); | ||
|
||
perfContext('write/string/async', () => { | ||
let terminal: Terminal; | ||
before(() => { | ||
terminal = new Terminal({ cols: 80, rows: 25, scrollback: 1000 }); | ||
fakedAddonLoad(terminal); | ||
}); | ||
new ThroughputRuntimeCase('', async () => { | ||
await new Promise<void>(res => terminal.write(content, res)); | ||
return { payloadSize: contentUtf8.length }; | ||
}, { fork: false }).showAverageThroughput(); | ||
}); | ||
|
||
perfContext('write/Utf8/async', () => { | ||
let terminal: Terminal; | ||
before(() => { | ||
terminal = new Terminal({ cols: 80, rows: 25, scrollback: 1000 }); | ||
}); | ||
new ThroughputRuntimeCase('', async () => { | ||
await new Promise<void>(res => terminal.write(content, res)); | ||
return { payloadSize: contentUtf8.length }; | ||
}, { fork: false }).showAverageThroughput(); | ||
}); | ||
}); |
19 changes: 19 additions & 0 deletions
19
addons/xterm-addon-unicode-graphemes/benchmark/benchmark.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"APP_PATH": ".benchmark", | ||
"evalConfig": { | ||
"tolerance": { | ||
"*": [0.75, 1.5], | ||
"*.dev": [0.01, 1.5], | ||
"*.cv": [0.01, 1.5], | ||
"EscapeSequenceParser.benchmark.js.*.averageThroughput.mean": [0.9, 5] | ||
}, | ||
"skip": [ | ||
"*.median", | ||
"*.runs", | ||
"*.dev", | ||
"*.cv", | ||
"EscapeSequenceParser.benchmark.js.*.averageRuntime", | ||
"Terminal.benchmark.js.*.averageRuntime" | ||
] | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
addons/xterm-addon-unicode-graphemes/benchmark/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": ["dom", "es6"], | ||
"outDir": "../out-benchmark", | ||
"types": ["../../../node_modules/@types/node"], | ||
"moduleResolution": "node", | ||
"strict": false, | ||
"target": "es2015", | ||
"module": "commonjs", | ||
"baseUrl": ".", | ||
"paths": { | ||
"common/*": ["../../../src/common/*"], | ||
"browser/*": ["../../../src/browser/*"], | ||
"UnicodeGraphemeProvider": ["../src/UnicodeGraphemeProvider"] | ||
} | ||
}, | ||
"include": ["../**/*", "../../../typings/xterm.d.ts"], | ||
"exclude": ["../../../**/*test.ts", "../../**/*api.ts"], | ||
"references": [ | ||
{ "path": "../../../src/common" }, | ||
{ "path": "../../../src/browser" } | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 10 additions & 7 deletions
17
addons/xterm-addon-unicode-graphemes/src/UnicodeProperties.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters