| 109 | } |
| 110 | |
| 111 | int main(int argc, char* argv[]) { |
| 112 | const char* dbpath = "./db"; |
| 113 | int ch, max = 1000, nthread = 1; |
| 114 | acl::string action("get"); |
| 115 | |
| 116 | while ((ch = getopt(argc, argv, "hn:a:c:")) > 0) { |
| 117 | switch (ch) { |
| 118 | case 'h': |
| 119 | usage(argv[0]); |
| 120 | return 0; |
| 121 | case 'n': |
| 122 | max = atoi(optarg); |
| 123 | break; |
| 124 | case 'a': |
| 125 | action = optarg; |
| 126 | break; |
| 127 | case 'c': |
| 128 | nthread = atoi(optarg); |
| 129 | break; |
| 130 | default: |
| 131 | break; |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | std::vector<acl::thread*> threads; |
| 136 | for (int i = 0; i < nthread; i++) { |
| 137 | DB* db; |
| 138 | Options options; |
| 139 | options.IncreaseParallelism(); |
| 140 | // options.OptimizeLevelStyleCompaction(); |
| 141 | options.create_if_missing = true; |
| 142 | |
| 143 | acl::string path; |
| 144 | path << dbpath << i; |
| 145 | Status s = DB::Open(options, path.c_str(), &db); |
| 146 | if (!s.ok()) { |
| 147 | printf("Open rockdb(%s) failed(%s)!\r\n", |
| 148 | dbpath, s.getState()); |
| 149 | return 1; |
| 150 | } |
| 151 | |
| 152 | acl::thread* thr = new db_thread(i, db, action, max); |
| 153 | threads.push_back(thr); |
| 154 | thr->start(); |
| 155 | } |
| 156 | |
| 157 | for (std::vector<acl::thread*>::iterator it = threads.begin(); |
| 158 | it != threads.end(); ++it) { |
| 159 | (*it)->wait(); |
| 160 | delete *it; |
| 161 | } |
| 162 | |
| 163 | return 0; |
| 164 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…