| 168 | } |
| 169 | |
| 170 | int main(int argc, char **argv) { |
| 171 | PredictorApi api; |
| 172 | |
| 173 | // initialize logger instance |
| 174 | #ifdef BCLOUD |
| 175 | logging::LoggingSettings settings; |
| 176 | settings.logging_dest = logging::LOG_TO_FILE; |
| 177 | |
| 178 | std::string filename(argv[0]); |
| 179 | filename = filename.substr(filename.find_last_of('/') + 1); |
| 180 | settings.log_file = (std::string("./log/") + filename + ".log").c_str(); |
| 181 | settings.delete_old = logging::DELETE_OLD_LOG_FILE; |
| 182 | logging::InitLogging(settings); |
| 183 | |
| 184 | logging::ComlogSinkOptions cso; |
| 185 | cso.process_name = filename; |
| 186 | cso.enable_wf_device = true; |
| 187 | logging::ComlogSink::GetInstance()->Setup(&cso); |
| 188 | #else |
| 189 | struct stat st_buf; |
| 190 | int ret = 0; |
| 191 | if ((ret = stat("./log", &st_buf)) != 0) { |
| 192 | mkdir("./log", 0777); |
| 193 | ret = stat("./log", &st_buf); |
| 194 | if (ret != 0) { |
| 195 | LOG(WARNING) << "Log path ./log not exist, and create fail"; |
| 196 | return -1; |
| 197 | } |
| 198 | } |
| 199 | FLAGS_log_dir = "./log"; |
| 200 | google::InitGoogleLogging(strdup(argv[0])); |
| 201 | FLAGS_logbufsecs = 0; |
| 202 | FLAGS_logbuflevel = -1; |
| 203 | #endif |
| 204 | |
| 205 | g_pred_labels.clear(); |
| 206 | |
| 207 | std::shared_ptr<DataFeed> local_feed(new DataFeed()); |
| 208 | local_feed->init(); |
| 209 | local_feed->set_file(g_test_file); |
| 210 | |
| 211 | if (api.create("./conf", "predictors.prototxt") != 0) { |
| 212 | LOG(ERROR) << "Failed create predictors api!"; |
| 213 | return -1; |
| 214 | } |
| 215 | |
| 216 | Request req; |
| 217 | Response res; |
| 218 | |
| 219 | api.thrd_initialize(); |
| 220 | |
| 221 | uint64_t elapse_ms = 0; |
| 222 | int batch_count = 0; |
| 223 | while (true) { |
| 224 | api.thrd_clear(); |
| 225 | |
| 226 | Predictor *predictor = api.fetch_predictor("text_classification"); |
| 227 | if (!predictor) { |
nothing calls this directly
no test coverage detected