MCPcopy Create free account
hub / github.com/4paradigm/OpenMLDB / HandleClientBenScan

Function HandleClientBenScan

src/cmd/fedb.cc:4829–4878  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4827}
4828
4829void HandleClientBenScan(const std::vector<std::string>& parts,
4830 ::fedb::client::TabletClient* client) {
4831 uint64_t et = 0;
4832 uint32_t tid = 1;
4833 uint32_t pid = 1;
4834 uint64_t key_num = 1000000;
4835 uint32_t times = 10000;
4836 int num = 100;
4837 uint32_t limit = 0;
4838 if (parts.size() >= 3) {
4839 try {
4840 tid = ::boost::lexical_cast<uint32_t>(parts[1]);
4841 pid = ::boost::lexical_cast<uint32_t>(parts[2]);
4842 if (parts.size() >= 4) {
4843 key_num = ::boost::lexical_cast<uint64_t>(parts[3]);
4844 }
4845 if (parts.size() >= 5) {
4846 times = ::boost::lexical_cast<uint32_t>(parts[4]);
4847 }
4848 if (parts.size() >= 6) {
4849 num = ::boost::lexical_cast<int>(parts[5]);
4850 }
4851 if (parts.size() >= 7) {
4852 limit = ::boost::lexical_cast<uint32_t>(parts[6]);
4853 }
4854 } catch (boost::bad_lexical_cast& e) {
4855 std::cout << "Bad scan format" << std::endl;
4856 return;
4857 }
4858 }
4859 uint64_t base = 100000000;
4860 std::random_device rd;
4861 std::default_random_engine engine(rd());
4862 std::uniform_int_distribution<> dis(1, key_num);
4863 std::string msg;
4864 while (num > 0) {
4865 for (uint32_t i = 0; i < times; i++) {
4866 std::string key = std::to_string(base + dis(engine));
4867 uint64_t st = ::baidu::common::timer::get_micros() / 1000;
4868 msg.clear();
4869 // ::fedb::base::KvIterator* it = client->Scan(tid, pid,
4870 // key.c_str(), st, et, msg, false);
4871 ::fedb::base::KvIterator* it =
4872 client->Scan(tid, pid, key.c_str(), st, et, limit, 0, msg);
4873 delete it;
4874 }
4875 client->ShowTp();
4876 num--;
4877 }
4878}
4879
4880void StartClient() {
4881 if (FLAGS_endpoint.empty()) {

Callers 1

StartClientFunction · 0.85

Calls 5

to_stringFunction · 0.85
clearMethod · 0.80
ShowTpMethod · 0.80
sizeMethod · 0.45
ScanMethod · 0.45

Tested by

no test coverage detected