Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rapidjson::Document documentR;
- Json::Value testJson;
- int32 keyCount = 0;
- while (keyCount < 100000)
- {
- std::string index = std::to_string(keyCount);
- rapidjson::Value _data;
- _data.AddMember("active", true, documentR.GetAllocator());
- _data.AddMember("disabled", false, documentR.GetAllocator());
- _data.AddMember("state", PLAYERSPELL_REMOVED, documentR.GetAllocator());
- documentR.AddMember(rapidjson::StringRef(index.c_str()), _data, documentR.GetAllocator());
- keyCount++;
- }
- //Add 37 ms
- keyCount = 0;
- while (keyCount < 100000)
- {
- std::string index = std::to_string(keyCount);
- Json::Value temp;
- temp["active"] = true;
- temp["disabled"] = false;
- temp["state"] = 2;
- testJson[index.c_str()] = temp;
- keyCount++;
- }
- //Add 264 ms
- keyCount = 0;
- while (keyCount < 100000)
- {
- int32 randKey = urand(1, 100000);
- std::string index = std::to_string(randKey);
- rapidjson::Value::ConstMemberIterator itr = documentR.FindMember(index.c_str());
- bool testBool = itr != documentR.MemberEnd() ? itr->value["active"].GetBool() : 0;
- keyCount++;
- }
- //Find 3535 ms
- keyCount = 0;
- while (keyCount < 100000)
- {
- int32 randKey = urand(1, 100000);
- std::string index = std::to_string(randKey);
- bool testBool = documentR[index.c_str()]["active"].GetBool();
- keyCount++;
- }
- //Get 3518 ms
- keyCount = 0;
- while (keyCount < 100000)
- {
- int32 randKey = urand(1, 100000);
- std::string index = std::to_string(randKey);
- bool testBool = testJson[index.c_str()]["active"].asBool();
- keyCount++;
- }
- //Get 125 ms
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement