1 #include <boost/program_options.hpp>
2 #include <boost/shared_ptr.hpp>
7 #include "protobufrpc.h"
9 using namespace bicker;
10 using namespace boost;
11 using namespace kvstore;
14 namespace po = boost::program_options;
19 KVBench(const vector<string> &hosts)
20 :_kv_client(list<string>(hosts.begin(), hosts.end()))
29 void Bench(const size_t size,
32 string data(size, 'A');
34 for (size_t i = 0; i < count; ++i)
37 key << "key_" << size << "_" << i << endl;
39 _kv_client.Put(key.str(), data);
42 for (size_t i = 0; i < count; ++i)
46 key << "key_" << size << "_" << i << endl;
48 _kv_client.Get(key.str(), &value);
53 KeyValueClient _kv_client;
67 po::options_description options("Options");
70 ("help,h", "display help message")
72 po::value< vector<string> >()->multitoken(),
73 "server:port ... server:port")
75 po::value<size_t>(&opt_low)->default_value(1),
78 po::value<size_t>(&opt_high)->default_value(16),
81 po::value<size_t>(&opt_count)->default_value(100),
86 po::store(po::parse_command_line(argc, argv, options), vm);
91 cerr << options << endl;
95 if (!vm.count("servers"))
97 cerr << "No Servers Specified" << endl;
102 KVBench bench(vm["servers"].as< vector<string> >());
104 for (size_t i = opt_low; i <= opt_high; ++i)
106 cout << i << ": " << (1<<i) << endl;
107 bench.Bench(1<<i, opt_count);