Tencent/rapidjson

Optimize integer-to-string conversion in GenericWriter

miloyip opened this issue · 3 comments

Current implementation is a basic algorithm which costs one division per decimal digit.
Compare with other faster implementations and adopt suitable algorithm.

pah commented

Instead of maintaining a custom algorithm, another option might be to rely on default conversions from the C/C++ runtime and optionally provide a customization for (embedded) platforms without suitable implementations.

Yes. Can try using sprintf("%d") but probably it should be the worst case, like this.
I have seen some better double to string conversion routines around as well.

Since doing performance testing in current unit test is quite difficult, I have spent a week to create a side project itoa-benchmark.

This results show that, branchlut should be a good candidate to replace the "naive" implementation in RapidJSON. sse2 implementation has only minor performance gain over branchlut.

I have spent quite some time with Google Charts but I will reuse the framework for creating the JSON benchmark in near future.