The FPC tests were done on Linux x86_64 with FPC 3.2.0 and -O3.
So it is properly inlined, and uses our x86_64 memory manager written in asm.
Which are the recommended settings for a production server. You get similar results on Win64.
I guess you are using Win32 with the default FPC memory manager.
Some numbers are indeed irrelevant when comparing to other parsers - but meaningful anyway, since they are used within the framework and I wanted to have wide benchmark values. For instance, IsValidUtf8() on x86_64 is around 13GB/s on my AVX2 CPU.
The relevant parsers, making a full parsing and extracting, are indeed:
- TDocVariant = object/array nodes parser storing values as variants, stored in a TDocVariantData record which could be mapped as a custom variant type;
- TOrmTableJson = array parser, optimized for an ORM list, with in-place unescape and #0 ending, creating a list of PUtf8Char to each value;
- DynArrayLoadJson = array parser, filling a dynamic array of records with all values.
As I wrote after this initial post, the initial numbers above were wrong about fpjson, due to an invalid length in the calculation. I have then published new values.
I have rewritten the JSON validator to be stronger and also slightly faster.
With the latest JSON validator (which I will commit in the next hours), here are some updated numbers:
- JSON benchmark: 100,307 assertions passed 843.40ms
StrLen() in 826us, 23.1 GB/s
IsValidUtf8(RawUtf8) in 1.46ms, 13 GB/s
IsValidUtf8(PUtf8Char) in 2.29ms, 8.3 GB/s
IsValidJson(RawUtf8) in 20.74ms, 0.9 GB/s
IsValidJson(PUtf8Char) in 20.95ms, 0.9 GB/s
JsonArrayCount(P) in 20.12ms, 0.9 GB/s
JsonArrayCount(P,PMax) in 19.97ms, 0.9 GB/s
JsonObjectPropCount() in 10.98ms, 1 GB/s
TDocVariant in 123.71ms, 158.4 MB/s
TDocVariant dvoInternNames in 146.39ms, 133.9 MB/s
TOrmTableJson GetJsonValues in 24.31ms, 354.5 MB/s
TOrmTableJson expanded in 39.12ms, 501 MB/s
TOrmTableJson not expanded in 20.89ms, 412.6 MB/s
DynArrayLoadJson in 61.68ms, 317.8 MB/s
fpjson in 79.39ms, 24.6 MB/s
jsontools in 50.50ms, 38.8 MB/s
SuperObject in 184.59ms, 10.6 MB/s
The numbers slightly change during each call on my Core i5 laptop, but the order of magnitude remains.
DynArrayLoadJson is almost 13 times faster than fpjson, and TOrmTableJson is 20 times faster. TDocVariant is "only" 6 times faster, and if you intern the names (i.e. you don't allocate a string for each property name, but reuse an existing string with refcnt + 1 which reduces a lot the memory usage) it is slightly below 6 times faster.
Since jsontools is faster then fpjson, the numbers are lower for it, but DynArrayLoadJson is still 8 times faster than jsontools, with a lot less memory consumption.