From 674914bbb70437b421a48ec7e5c9f24a95b7d055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Sun, 9 Jun 2019 14:51:44 +0200 Subject: [PATCH] moving benchmarks out of './src': Harder than I thought for several reasons: - need access to common to tests the subparts, thus the unified tsconfig in tests does not work (need the path translation to those parts) - moving next to src I cannot use direct imports anymore (source files are out of rootDir), thus have to rely on d.ts files in out which is quite suboptimal as many parts do not expose the declaration files (can only type Terminal as any atm) - compiler output has to resemble the '../out/..' import logic of the TS files or require fails, thus moved the ouput to './benchmark' for now Conclusion: Not yet there, maybe not a good idea at all to move those tests out of './src' as they heavily rely on not exported internals. Needs more fiddling with the repo structure. --- .../EscapeSequenceParser.benchmark.ts | 6 ++--- .../Terminal.benchmark.ts | 15 ++++++----- benchmark-tests/benchmark.json | 18 +++++++++++++ benchmark-tests/tsconfig.json | 27 +++++++++++++++++++ tsconfig.all.json | 5 +++- 5 files changed, 61 insertions(+), 10 deletions(-) rename {src/core/parser => benchmark-tests}/EscapeSequenceParser.benchmark.ts (97%) rename {src => benchmark-tests}/Terminal.benchmark.ts (84%) create mode 100644 benchmark-tests/benchmark.json create mode 100644 benchmark-tests/tsconfig.json diff --git a/src/core/parser/EscapeSequenceParser.benchmark.ts b/benchmark-tests/EscapeSequenceParser.benchmark.ts similarity index 97% rename from src/core/parser/EscapeSequenceParser.benchmark.ts rename to benchmark-tests/EscapeSequenceParser.benchmark.ts index 392774dd..d64f5812 100644 --- a/src/core/parser/EscapeSequenceParser.benchmark.ts +++ b/benchmark-tests/EscapeSequenceParser.benchmark.ts @@ -4,9 +4,9 @@ */ import { perfContext, before, beforeEach, ThroughputRuntimeCase } from 'xterm-benchmark'; -import { EscapeSequenceParser } from 'core/parser/EscapeSequenceParser'; -import { C0, C1 } from 'common/data/EscapeSequences'; -import { IDcsHandler } from './Types'; +import { EscapeSequenceParser } from '../out/common/parser/EscapeSequenceParser'; +import { C0, C1 } from '../out/common/data/EscapeSequences'; +import { IDcsHandler } from '../out/common/parser/Types'; function toUtf32(s: string): Uint32Array { diff --git a/src/Terminal.benchmark.ts b/benchmark-tests/Terminal.benchmark.ts similarity index 84% rename from src/Terminal.benchmark.ts rename to benchmark-tests/Terminal.benchmark.ts index 650ed655..9e5e10bc 100644 --- a/src/Terminal.benchmark.ts +++ b/benchmark-tests/Terminal.benchmark.ts @@ -5,19 +5,22 @@ import { perfContext, before, ThroughputRuntimeCase } from 'xterm-benchmark'; -import { Terminal } from 'Terminal'; import { spawn } from 'node-pty'; -import { Utf8ToUtf32, stringFromCodePoint } from 'core/input/TextDecoder'; +import { Utf8ToUtf32, stringFromCodePoint } from '../out/common/input/TextDecoder'; +const Terminal: any = require('../out/Terminal').Terminal; class TestTerminal extends Terminal { + constructor(opts: any) { + super(opts); + } writeSync(data: string): void { this.writeBuffer.push(data); - this._innerWrite(); + (this as any)._innerWrite(); } writeSyncUtf8(data: Uint8Array): void { - this.writeBufferUtf8.push(data); - this._innerWriteUtf8(); + (this as any).writeBufferUtf8.push(data); + (this as any)._innerWriteUtf8(); } } @@ -33,7 +36,7 @@ perfContext('Terminal: ls -lR /usr', () => { rows: 25, cwd: process.env.HOME, env: process.env, - encoding: null + encoding: (null as unknown as string) // needs to be fixed in node-pty }); const chunks: Buffer[] = []; let length = 0; diff --git a/benchmark-tests/benchmark.json b/benchmark-tests/benchmark.json new file mode 100644 index 00000000..7d8e2223 --- /dev/null +++ b/benchmark-tests/benchmark.json @@ -0,0 +1,18 @@ +{ + "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" + ] + } +} diff --git a/benchmark-tests/tsconfig.json b/benchmark-tests/tsconfig.json new file mode 100644 index 00000000..02079d2b --- /dev/null +++ b/benchmark-tests/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "lib": [ + "dom", + "es6", + ], + "rootDir": ".", + "outDir": "../benchmark", + "types": [ + "../node_modules/@types/node" + ], + "sourceMap": true, + "removeComments": true, + "pretty": true, + "strict": true, + "baseUrl": ".", + "paths": { + "common/*": [ "./../out/common/*" ], + "browser/*": [ "./../out/browser/*" ] + }, + "declaration": true + }, + "include": [ + "./**/*", + "../typings/xterm.d.ts" + ] +} diff --git a/tsconfig.all.json b/tsconfig.all.json index d2670811..d8d8d20b 100644 --- a/tsconfig.all.json +++ b/tsconfig.all.json @@ -7,6 +7,9 @@ { "path": "./addons/xterm-addon-attach/src" }, { "path": "./addons/xterm-addon-fit/src" }, { "path": "./addons/xterm-addon-search/src" }, - { "path": "./addons/xterm-addon-web-links/src" } + { "path": "./addons/xterm-addon-web-links/src" }, + + // currently depends on out, thus must run as last? + { "path": "./benchmark-tests" }, ] }