lgJson now uses the Eisel-Lemire approximation algorithm for string-to-double conversion, and the Ryū algorithm for the reverse conversion.
The former is used exclusively as an internal function, but the Ryū implementation(Double2Str) has been made public and, accordingly, its performance can be compared with other double-to-string converters.
The selected subjects are divided into two groups: the first does not make an explicit memory allocation, and the second does.
The first group includes DoubleToShort from Mormot2, the built-in FloatToText, Double2Str(procedure) from lgJson and the built-in Str(shortstring).
The second includes DoubleToStr from Mormot2, the built-in FloatToStr, RyuDoubleToString from PasDblStrUtils, Double2Str(function) from lgJson and the built-in Str(string).
The benchmark generates an array of 10000000 random doubles and measures the time(ms) it takes to process the entire array(5 attempts, the best time is taken as the result).
Results:
1 x86_64 x86
---------------------------
DoubleToShort 1216 2106
Str 1918 4399
FloatToText 4321 7191
Double2Str 858 2761
---------------------------
2 x86_64 x86
-------------------------------
DoubleToStr 2480 3432
Str 2652 5163
FloatToStr 3588 6349
RyuDoubleToString 2589 7269
Double2Str 1482 3322
-------------------------------
It seems that parsing in lgJson has become noticeably faster, so it makes sense to run the parser benchmark again.
The list of samples has changed a bit and a parser from InternetTools (XQJsonParser) has been added. InternetTools was compiled with USE_PASDBLSTRUTILS define. The rest of the test subjects remained the same. The results on a win-64 machine can be seen in the attached bar chart.
Edit.
Sorry, incorrect data for the second group was provided. Fixed now.