-
-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need a std::map or unordered_map implementation. #346
Comments
Thanks for posting this, the results are quite interesting. It's uncommon to see json benchmarks that go beyond parsing and serializing. In terms of structure, nlohmann stores json objects as a Of note, by sticking to sequential data structures, jsoncons and rapidjson have more compact data representations and use less memory than nlohmann. But it seems jsoncons performs significantly poorer than nlohmann for inserts. I downloaded your project and did some experiments. I tried pre-allocating memory for the object storage with One thing though is that your test is inserting 500 key-value pairs into an object, that seems to me to be a lot of object members. On my machine, up until about 50 keys, which seems to me to be a more typical number, jsoncons is faster than nlohmann, than falls behind. However, let's suppose we want to match nlohmann for inserts of larger numbers (> 50) of key-value pairs. One option as you propose is to support As another option, note that appending all the new items to a vector and then sorting once at the end (which is what json j; // Original value
json_builder builder(std::move(j));
for (int i = 0; i < 500; ++i)
builder.insert(key,val); // appends
j = builder.get_result(); // sorts and moves result into j Any comments welcome. Daniel |
After considering this request, I think I want to stick to the flat map memory layout, I don't think I want to introduce |
Describe the proposed feature
add type
jsoncons::mjson (std::map or unordered_map implementation)
jsoncons::mojson (preserve order std::map or unordered_map implementation)
like
jsoncons::json (sort vector implementation)
jsoncons::ojson (preserve order sort vector implementation)
The performance of insert is too low.
https://github.com/nicehero/json_benchmark
And I love other featrues from this project such as proxy_type ,bson support etc.
nlohmann insert&erase times:1000 cost:0.000472 qps:2117616
jsoncons insert&erase times:1000 cost:0.011752 qps:85090
rapidjson insert&erase times:1000 cost:0.002199 qps:454700
jpg
The text was updated successfully, but these errors were encountered: