Replies: 1 comment 3 replies
-
@sndth YAML “looks“ much simpler than JSON, but it ISN'T simple as such or rather much more complicated in terms of its specification, in other words, requirements for parser implementation. That affects the performance as the benchmark scores in the README shows. Here is a case where YAML is more complicated than JSON, taking the snippets you shared above. A simple plain (unquoted) scalar, for example, has many more restrictions for allowed characters than quoted ones, and a not-allowed character such as |
Beta Was this translation helpful? Give feedback.
-
Although
YAML
is much simpler in its structure, and the file size is~200KB
smaller after converting fromJSON
toYAML
, the parsing time of the document is significantly slower compared to thenlohmann::json
. Here’s the benchmark using nanobench library:Debug (x86)
nlohmann::json
fkyaml
Debug (x64)
nlohmann::json
fkyaml
Release (x86)
nlohmann::json
fkyaml
Release (x64)
nlohmann::json
fkyaml
Example test code to reproduce:
test.yaml
test.json
Result on Debug x86:
nlohmann::json
fkyaml
Beta Was this translation helpful? Give feedback.
All reactions