Advertisement
blackmanos

Untitled

Mar 3rd, 2016
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. rapidjson::Document documentR;
  2. Json::Value testJson;
  3.  
  4. int32 keyCount = 0;
  5. while (keyCount < 100000)
  6. {
  7. std::string index = std::to_string(keyCount);
  8. rapidjson::Value _data;
  9.  
  10. _data.AddMember("active", true, documentR.GetAllocator());
  11. _data.AddMember("disabled", false, documentR.GetAllocator());
  12. _data.AddMember("state", PLAYERSPELL_REMOVED, documentR.GetAllocator());
  13.  
  14. documentR.AddMember(rapidjson::StringRef(index.c_str()), _data, documentR.GetAllocator());
  15.  
  16. keyCount++;
  17. }
  18. //Add 37 ms
  19.  
  20. keyCount = 0;
  21. while (keyCount < 100000)
  22. {
  23. std::string index = std::to_string(keyCount);
  24. Json::Value temp;
  25.  
  26. temp["active"] = true;
  27. temp["disabled"] = false;
  28. temp["state"] = 2;
  29.  
  30. testJson[index.c_str()] = temp;
  31.  
  32. keyCount++;
  33. }
  34. //Add 264 ms
  35.  
  36. keyCount = 0;
  37. while (keyCount < 100000)
  38. {
  39. int32 randKey = urand(1, 100000);
  40. std::string index = std::to_string(randKey);
  41. rapidjson::Value::ConstMemberIterator itr = documentR.FindMember(index.c_str());
  42. bool testBool = itr != documentR.MemberEnd() ? itr->value["active"].GetBool() : 0;
  43.  
  44. keyCount++;
  45. }
  46. //Find 3535 ms
  47.  
  48. keyCount = 0;
  49. while (keyCount < 100000)
  50. {
  51. int32 randKey = urand(1, 100000);
  52. std::string index = std::to_string(randKey);
  53. bool testBool = documentR[index.c_str()]["active"].GetBool();
  54.  
  55. keyCount++;
  56. }
  57. //Get 3518 ms
  58.  
  59. keyCount = 0;
  60. while (keyCount < 100000)
  61. {
  62. int32 randKey = urand(1, 100000);
  63. std::string index = std::to_string(randKey);
  64. bool testBool = testJson[index.c_str()]["active"].asBool();
  65.  
  66. keyCount++;
  67. }
  68. //Get 125 ms
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement