X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=kvstore%2Fkvbench.cc;fp=kvstore%2Fkvbench.cc;h=da25085985136280910b9b4a494bdf92a3e05cf7;hb=3c2cbef21a11c4d86952922f4da7b830a91423f9;hp=0000000000000000000000000000000000000000;hpb=db0d4c10ea7abfa2546f73e96784ebf554342977;p=bluesky.git diff --git a/kvstore/kvbench.cc b/kvstore/kvbench.cc new file mode 100644 index 0000000..da25085 --- /dev/null +++ b/kvstore/kvbench.cc @@ -0,0 +1,111 @@ +#include +#include +#include +#include +#include "kvservice.h" +#include "kvclient.h" +#include "protobufrpc.h" + +using namespace bicker; +using namespace boost; +using namespace kvstore; +using namespace std; + +namespace po = boost::program_options; + +class KVBench +{ +public: + KVBench(const vector &hosts) + :_kv_client(list(hosts.begin(), hosts.end())) + { + } + + virtual ~KVBench() + { + } + + + void Bench(const size_t size, + const size_t count) + { + string data(size, 'A'); + + for (size_t i = 0; i < count; ++i) + { + ostringstream key; + key << "key_" << size << "_" << i << endl; + + _kv_client.Put(key.str(), data); + } + + for (size_t i = 0; i < count; ++i) + { + string value; + ostringstream key; + key << "key_" << size << "_" << i << endl; + + _kv_client.Get(key.str(), &value); + } + } + +protected: + KeyValueClient _kv_client; +}; + + +int +main( + int argc, + char **argv + ) +{ + size_t opt_low; + size_t opt_high; + size_t opt_count; + + po::options_description options("Options"); + + options.add_options() + ("help,h", "display help message") + ("servers", + po::value< vector >()->multitoken(), + "server:port ... server:port") + ("low,l", + po::value(&opt_low)->default_value(1), + "low 2^i") + ("high,H", + po::value(&opt_high)->default_value(16), + "high 2^i") + ("count,c", + po::value(&opt_count)->default_value(100), + "count of each size") + ; + + po::variables_map vm; + po::store(po::parse_command_line(argc, argv, options), vm); + po::notify(vm); + + if (vm.count("help")) + { + cerr << options << endl; + return 1; + } + + if (!vm.count("servers")) + { + cerr << "No Servers Specified" << endl; + return 1; + } + + + KVBench bench(vm["servers"].as< vector >()); + + for (size_t i = opt_low; i <= opt_high; ++i) + { + cout << i << ": " << (1<