| 128 | }; |
| 129 | |
| 130 | bool parseCommandLine(std::list<std::string> &args, BenchParams &benchParams) |
| 131 | { |
| 132 | bool collectSamples = false; |
| 133 | |
| 134 | for (auto it = args.begin(); it != args.end();) |
| 135 | { |
| 136 | const std::string arg = *it; |
| 137 | |
| 138 | if (arg == "-help") |
| 139 | { |
| 140 | collectSamples = false; |
| 141 | benchParams.type = BenchType::HELP; |
| 142 | } |
| 143 | else if (arg == "-type") |
| 144 | { |
| 145 | collectSamples = false; |
| 146 | ++it; |
| 147 | if (it != args.end()) |
| 148 | { |
| 149 | const std::string str_type = *it; |
| 150 | if (str_type == "initField") |
| 151 | { |
| 152 | benchParams.type = BenchType::INIT_FIELD; |
| 153 | } |
| 154 | else if (str_type == "benchLookUpSample") |
| 155 | { |
| 156 | benchParams.type = BenchType::BENCH_LOOKUP_SAMPLE; |
| 157 | } |
| 158 | else if (str_type == "benchLookUp") |
| 159 | { |
| 160 | benchParams.type = BenchType::BENCH_LOOKUP; |
| 161 | } |
| 162 | else |
| 163 | { |
| 164 | std::cout << "ERROR: Unknown type: " << str_type << std::endl; |
| 165 | std::cout << " Valid types are: [initField benchLookUp benchLookUpSample] " << std::endl; |
| 166 | return false; |
| 167 | } |
| 168 | } |
| 169 | else |
| 170 | { |
| 171 | return false; |
| 172 | } |
| 173 | } |
| 174 | else if (arg == "-device") |
| 175 | { |
| 176 | collectSamples = false; |
| 177 | ++it; |
| 178 | if (it != args.end()) |
| 179 | { |
| 180 | const std::string str_type = *it; |
| 181 | if (str_type == "CPU_4") |
| 182 | { |
| 183 | benchParams.device_type = PGL_DEVICE_TYPE_CPU_4; |
| 184 | } |
| 185 | else if (str_type == "CPU_8") |
| 186 | { |
| 187 | benchParams.device_type = PGL_DEVICE_TYPE_CPU_8; |