-
Notifications
You must be signed in to change notification settings - Fork 79
benchmark each module in their own node process #866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7113bfe
benchmark each module in their own node process
hoeck f63bfbd
fix spectypes .eslintignore
hoeck 80753e4
fix eslint complaints
hoeck d58be44
add info to readme about the change
hoeck ea914ab
more emphasis to readme info message
hoeck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,3 +1,3 @@ | ||
**/node_modules | ||
docs/dist | ||
compiled/spectypes/build | ||
cases/spectypes/build |
This file contains hidden or 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,5 +1,8 @@ | ||
{ | ||
"extends": "./node_modules/gts/", | ||
"rules": { | ||
"node/no-unpublished-import": "off" | ||
}, | ||
"env": { | ||
"jest": true | ||
} | ||
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,28 +1,36 @@ | ||
import './ajv'; | ||
import './bueno'; | ||
import './class-validator'; | ||
import './computed-types'; | ||
import './decoders'; | ||
import './io-ts'; | ||
import './jointz'; | ||
import './json-decoder'; | ||
import './marshal'; | ||
import './mojotech-json-type-validation'; | ||
import './myzod'; | ||
import './ok-computer'; | ||
import './purify-ts'; | ||
import './rulr'; | ||
import './runtypes'; | ||
import './simple-runtypes'; | ||
import './spectypes'; | ||
import './superstruct'; | ||
import './suretype'; | ||
import './toi'; | ||
import './tson'; | ||
import './ts-interface-checker'; | ||
import './ts-json-validator'; | ||
import './ts-utils'; | ||
import './typeofweb-schema'; | ||
import './valita'; | ||
import './yup'; | ||
import './zod'; | ||
export const cases = [ | ||
'ajv', | ||
'bueno', | ||
'class-validator', | ||
'computed-types', | ||
'decoders', | ||
'io-ts', | ||
'jointz', | ||
'json-decoder', | ||
'marshal', | ||
'mojotech-json-type-validation', | ||
'myzod', | ||
'ok-computer', | ||
'purify-ts', | ||
'rulr', | ||
'runtypes', | ||
'simple-runtypes', | ||
'spectypes', | ||
'superstruct', | ||
'suretype', | ||
'toi', | ||
'ts-interface-checker', | ||
'ts-json-validator', | ||
'ts-utils', | ||
'tson', | ||
'typeofweb-schema', | ||
'valita', | ||
'yup', | ||
'zod', | ||
] as const; | ||
|
||
export type CaseName = typeof cases[number]; | ||
|
||
export async function importCase(caseName: CaseName) { | ||
await import('./' + caseName); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,4 +1,71 @@ | ||
import { main } from './benchmarks'; | ||
import './cases'; | ||
import * as childProcess from 'child_process'; | ||
import * as benchmarks from './benchmarks'; | ||
import * as cases from './cases'; | ||
|
||
main(); | ||
async function main() { | ||
// a runtype lib would be handy here to check the passed command names ;) | ||
const [command, ...args] = process.argv.slice(2); | ||
|
||
switch (command) { | ||
case undefined: | ||
case 'run': | ||
// run the given or all benchmarks, each in its own node process, see | ||
// https://github.com/moltar/typescript-runtime-type-benchmarks/issues/864 | ||
{ | ||
console.log('Removing previous results'); | ||
benchmarks.deleteResults(); | ||
|
||
const caseNames = args.length ? args : cases.cases; | ||
|
||
for (const c of caseNames) { | ||
if (c === 'spectypes') { | ||
// hack: manually run the spectypes compilation step - avoids | ||
// having to run it before any other benchmark, esp when working | ||
// locally and checking against a few selected ones. | ||
childProcess.execSync('npm run compile:spectypes', { | ||
stdio: 'inherit', | ||
}); | ||
} | ||
|
||
const cmd = [...process.argv.slice(0, 2), 'run-internal', c]; | ||
|
||
console.log('Executing "%s"', c); | ||
childProcess.execSync(cmd.join(' '), { | ||
stdio: 'inherit', | ||
}); | ||
} | ||
} | ||
break; | ||
|
||
case 'create-preview-svg': | ||
// separate command, because preview generation needs the accumulated | ||
// results from the benchmark runs | ||
await benchmarks.createPreviewGraph(); | ||
break; | ||
|
||
case 'run-internal': | ||
// run the given benchmark(s) & append the results | ||
{ | ||
const caseNames = args as cases.CaseName[]; | ||
|
||
for (const c of caseNames) { | ||
console.log('Loading "%s"', c); | ||
|
||
await cases.importCase(c); | ||
} | ||
|
||
await benchmarks.runAllBenchmarks(); | ||
} | ||
break; | ||
|
||
default: | ||
console.error('unknown command:', command); | ||
|
||
// eslint-disable-next-line no-process-exit | ||
process.exit(1); | ||
} | ||
} | ||
|
||
main().catch(e => { | ||
throw e; | ||
}); |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.