| 277 | } |
| 278 | } |
| 279 | int main(int argc, char** argv) { |
| 280 | google::ParseCommandLineFlags(&argc, &argv, true); |
| 281 | |
| 282 | // initialize |
| 283 | PredictorApi api; |
| 284 | response_time.resize(FLAGS_concurrency); |
| 285 | |
| 286 | #ifdef BCLOUD |
| 287 | logging::LoggingSettings settings; |
| 288 | settings.logging_dest = logging::LOG_TO_FILE; |
| 289 | std::string log_filename(argv[0]); |
| 290 | log_filename = log_filename.substr(log_filename.find_last_of('/') + 1); |
| 291 | settings.log_file = (std::string("./log/") + log_filename + ".log").c_str(); |
| 292 | settings.delete_old = logging::DELETE_OLD_LOG_FILE; |
| 293 | logging::InitLogging(settings); |
| 294 | logging::ComlogSinkOptions cso; |
| 295 | cso.process_name = log_filename; |
| 296 | cso.enable_wf_device = true; |
| 297 | logging::ComlogSink::GetInstance()->Setup(&cso); |
| 298 | #else |
| 299 | struct stat st_buf; |
| 300 | int ret = 0; |
| 301 | if ((ret = stat("./log", &st_buf)) != 0) { |
| 302 | mkdir("./log", 0777); |
| 303 | ret = stat("./log", &st_buf); |
| 304 | if (ret != 0) { |
| 305 | LOG(WARNING) << "Log path ./log not exist, and create fail"; |
| 306 | return -1; |
| 307 | } |
| 308 | } |
| 309 | FLAGS_log_dir = "./log"; |
| 310 | google::InitGoogleLogging(strdup(argv[0])); |
| 311 | FLAGS_logbufsecs = 0; |
| 312 | FLAGS_logbuflevel = -1; |
| 313 | #endif |
| 314 | // predictor conf |
| 315 | if (api.create("./conf", "predictors.prototxt") != 0) { |
| 316 | LOG(ERROR) << "Failed create predictors api!"; |
| 317 | return -1; |
| 318 | } |
| 319 | |
| 320 | LOG(INFO) << "data sample file: " << data_filename; |
| 321 | |
| 322 | if (FLAGS_enable_profiling) { |
| 323 | LOG(INFO) << "In profiling mode, lot of normal output will be supressed. " |
| 324 | << "Use --enable_profiling=false to turn off this mode"; |
| 325 | } |
| 326 | |
| 327 | // read data |
| 328 | std::ifstream data_file(data_filename); |
| 329 | if (!data_file) { |
| 330 | std::cout << "read file error \n" << std::endl; |
| 331 | return -1; |
| 332 | } |
| 333 | |
| 334 | std::vector<std::string> data_list; |
| 335 | std::string line; |
| 336 | while (getline(data_file, line)) { |