Skip to content

Conversation

@Simulant87
Copy link
Contributor

@Simulant87 Simulant87 commented Feb 22, 2024

Implementation for #863

Using a StringBuilder to improve the performance for the default toString methods without indent.

This duplicates a lot of code, as I assume you want to keep the existing public method interfaces accepting and returning a Writer for backwards compatibility. But is results in ~25% faster toString method, mostly used for serialisation.

I validated the performance with this project: https://github.com/fabienrenaud/java-json-benchmark
./run ser --libs ORGJSON

on my local machine result for the benchmark (thoughput measured in operations per second, higher is better):

currently latest library version 20240205:

Benchmark               Mode  Cnt       Score       Error  Units
Serialization.orgjson  thrpt   20  719375,045 ▒ 63677,634  ops/s

Improved implementation from this PR:

Benchmark               Mode  Cnt       Score       Error  Units
Serialization.orgjson  thrpt   20  905794,579 ▒ 23428,330  ops/s

@Simulant87
Copy link
Contributor Author

Closed in favour of #867 as it has comparable or even better performance with way less code changes and no code duplication.

@Simulant87 Simulant87 closed this Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant