-
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.
improve logger
- Loading branch information
Showing
13 changed files
with
180 additions
and
19 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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Benchmark | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
|
||
permissions: | ||
contents: write | ||
deployments: write | ||
|
||
jobs: | ||
benchmark: | ||
name: Check performances | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: '.nvmrc' | ||
|
||
- name: Build | ||
run: yarn build | ||
|
||
- name: Run benchmark | ||
run: yarn benchmark | tee output.txt | ||
|
||
- name: Store benchmark result | ||
uses: rhysd/github-action-benchmark@v1 | ||
with: | ||
name: '"with ts-gql-plugin" vs "without ts-gql-plugin" Benchmark' | ||
tool: 'benchmarkjs' | ||
output-file-path: output.txt | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
auto-push: true | ||
alert-threshold: '130%' | ||
comment-always: true | ||
comment-on-alert: true | ||
fail-on-alert: true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env ts-node | ||
|
||
import Benchmark, { Suite } from 'benchmark'; | ||
import { execSync } from 'node:child_process'; | ||
|
||
/** | ||
* Run benchmark comparing "with plugin" vs "without plugin". | ||
* Log diff in %. | ||
* | ||
* `yarn build` should be done before this process. | ||
*/ | ||
|
||
const runBenchmark = (): void => { | ||
const suite = new Suite() | ||
.add('compilation with plugin', () => { | ||
execSync('yarn tsc-ls -b ./example/tsconfig.benchmark1.json --force'); | ||
}) | ||
.add('compilation without plugin', () => { | ||
execSync('yarn tsc-ls -b ./example/tsconfig.benchmark2.json --force'); | ||
}) | ||
.run(); | ||
|
||
const benchmarks: Benchmark[] = suite.slice(0, suite.length); | ||
const withPluginsBench = benchmarks[0]; | ||
const withoutPluginsBench = benchmarks[1]; | ||
|
||
const rmeMax = Math.max( | ||
withPluginsBench.stats.rme, | ||
withoutPluginsBench.stats.rme | ||
); | ||
|
||
// if uncertainty of measurement is >10%, re-run benchmark | ||
if (rmeMax > 10) { | ||
return runBenchmark(); | ||
} | ||
|
||
/* eslint-disable no-mixed-operators */ | ||
const diffPercent = Math.max( | ||
100 - (withPluginsBench.hz * 100) / withoutPluginsBench.hz, | ||
0 | ||
); | ||
|
||
const name = | ||
'performance impact %: "with ts-gql-plugin" vs "without ts-gql-plugin"'; | ||
const value = diffPercent.toFixed(2); | ||
const unit = '%'; | ||
const pm = '\u00B1'; | ||
const rme = rmeMax.toFixed(2); | ||
const size = | ||
withPluginsBench.stats.sample.length + | ||
withoutPluginsBench.stats.sample.length; | ||
|
||
console.log(`${name} x ${value} ${unit} ${pm}${rme}% (${size} runs sampled)`); | ||
}; | ||
|
||
runBenchmark(); |
This file was deleted.
Oops, something went wrong.
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,17 @@ | ||
{ | ||
"extends": "../tsconfig.base.json", | ||
"compilerOptions": { | ||
"composite": true, | ||
"tsBuildInfoFile": "./node_modules/.cache/.tsbuildinfo", | ||
"outDir": "./node_modules/.cache/dist", | ||
"moduleResolution": "node", | ||
"plugins": [ | ||
{ | ||
"name": "ts-gql-plugin", | ||
"logLevel": "debug", | ||
"projectNameRegex": "([A-Z][a-z]*)" | ||
} | ||
] | ||
}, | ||
"include": ["index.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,10 @@ | ||
{ | ||
"extends": "../tsconfig.base.json", | ||
"compilerOptions": { | ||
"composite": true, | ||
"tsBuildInfoFile": "./node_modules/.cache/.tsbuildinfo", | ||
"outDir": "./node_modules/.cache/dist", | ||
"moduleResolution": "node" | ||
}, | ||
"include": ["index.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
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