-
-
Notifications
You must be signed in to change notification settings - Fork 172
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
JSON Schema | TypeBox Benchmark #253
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, it seems exciting. I'll update README's benchmark graphs soon
All good :) Hey, just for Ajv benchmarking, you should be able to replace the following code.... export const __TypeBoxUltimateUnion = Type.Array(Application(Schema));
export const TypeBoxUltimateUnion = TypeCompiler.Compile(
__TypeBoxUltimateUnion,
); With this code... import Ajv from 'ajv'
// ...
export const __TypeBoxUltimateUnion = Type.Array(Application(Schema));
const ajv = new Ajv()
const check = ajv.compile(__TypeBoxUltimateUnion)
export const TypeBoxUltimateUnion = {
Check: (input: unknown) => check(input) as boolean
} This should be enough to swap from the Good work on TSON btw, it's looking good :) |
Your typebox is really fast. About ultimate type, I will fix it. Thanks |
I understood the reason why your library is much faster. It sometimes do not wrap an object type as a function. However, I can show you how dangerous such optimization can be. I wanna repeat that again, |
Sure. But you may want to include the const Line = Type.Object({
p1: Point,
p2: Point,
}, { additionalProperties: false }); // <-- include here
TB is somewhat tied to the validation capabilities of the JSON Schema specification, so not sure it's possible to update the existing algorithm, but happy to take a look. Do you have a link / reference to the algo? |
This code never be finished. Is it bug? or have I developed something wrong? |
Oops, understood. |
@samchon TypeBox returns an return [...TypeBoxObjectHeirarchical.Errors(input)] However, it's going to be REALLY slow to do that. Note that TypeBox treats errors as a optional query you would run upon on validation failure, and it performs a secondary dynamic validation to gather errors (so no optimizations). You can include this if you want (tho |
Then only |
This PR implements benchmarks for JSON Schema comparative benchmarking. The benchmarks are implemented using the TypeBox type compiler for reference. As TypeBox generates JSON Schema Draft 6 compatible schemas, it should be possible to pass these schemas directly to Ajv for compilation also (see update below)
This PR is submitted both for comparative benchmarking, and to potentially provide a reference model for JSON Schema generation in
typescript-json
. The new benchmarks should pass all currentis
,validate
andassert
measurements, however it would be good to replace the TypeBox type compiler with Ajv to get good visibility on performance deltas there.Submitting for consideration