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
Generalize benchmarks #532
Closed
Closed
Conversation
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 allows surrogates anywhere in the input, compatible with the json module from the standard library. This also refactors two interfaces: - The `PyUnicode` to `char*` conversion is moved into its own function, separated from the `JSONTypeContext` handling, so it can be reused for other things in the future (e.g. indentation and separators) which don't have a type context. - Converting the `char*` output to a Python string with surrogates intact requires the string length for `PyUnicode_Decode` & Co. While `strlen` could be used, the length is already known inside the encoder, so the encoder function now also takes an extra `size_t` pointer argument to return that and no longer NUL-terminates the string. This also permits output that contains NUL bytes (even though that would be invalid JSON), e.g. if an object's `__json__` method return value were to contain them. Fixes ultrajson#156 Fixes ultrajson#447 Supersedes ultrajson#284
[pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Fix compiler warnings Update python/objToJSON.c Co-authored-by: JustAnotherArchivist <JustAnotherArchivist@users.noreply.github.com> camelCase whitespace Update tests/test_ujson.py Co-authored-by: JustAnotherArchivist <JustAnotherArchivist@users.noreply.github.com>
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
I don't see anything wrong with the benchmark picking up dependencies for graphics or for doing the timing (although it's intersting to see yet another |
Closed in favor of #542 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
In an effort to procrastinate on what I really need to be doing I did a rework of the existing benchmarks script, and I added a new one based on my timerit module (https://github.com/Erotemic/timerit/).
It's still a work in progress, because I do have to stop procrastinating, but here is a teaser plot that visually compares implementation performance on specific tasks over a range of sizes. Error bars included.
This branch is currently based on another PR, but I do plan to clean it up / factor out additional dependencies if that is desired.
To make the nice plots it will depend on seaborn and pandas. For timing, I do want to use
timerit
instead oftimeit
as it makes the benchmarks much easier to write. I could factor out ubelt, but it's small and I do find it useful.The main dependency that could be excluded is openskill, which is used to generate overall probability estimates that one library is faster than another. (Although currently nujson is slightly beating ujson, but maybe that's just because my PR has a slowdown). Part of the point of this is to determine when a patch introduces a performance regression.