-
-
Notifications
You must be signed in to change notification settings - Fork 209
Worse performance with response schema when 'const' keyword is used #502
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
Comments
Very interesting! This looks like a bug in fast-json-stringify. I'll move the bug there. |
How is the performance if we also use type: "string" or if we use enum instead of const? |
I would say it is expected. Lines 869 to 874 in d14112b
|
But i can determine the type of const before i use it in ajv. So do we have to improve the docs or should we write a function which traverses the entries for const and determines the corresponding type? |
+1 to mention it in the docs and open a new fresh issue to optimize it as we can. |
Prerequisites
Fastify version
4.3.0
Plugin version
No response
Node.js version
16.13.0
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
13.0
Description
When specifying the response schema with 'const' I noticed that the RPS decreased.
Steps to Reproduce
Options used:
Schema benchmark:

Options used:
Schema with const:

Repository with the code: https://github.com/DanieleFedeli/fastify-response-schema-issue
Expected Behavior
I expect at least the same performance when specifying const in the schema.
The text was updated successfully, but these errors were encountered: