| 542 | }); |
| 543 | } |
| 544 | void runTableBenchmark(const OSRM &osrm, const GPSTraces &gpsTraces, int iterations) |
| 545 | { |
| 546 | struct Benchmark |
| 547 | { |
| 548 | std::string name; |
| 549 | size_t coordinates; |
| 550 | }; |
| 551 | |
| 552 | std::vector<Benchmark> benchmarks = {{"250 tables, 3 coordinates", 3}, |
| 553 | {"250 tables, 25 coordinates", 25}, |
| 554 | {"250 tables, 50 coordinates", 50}}; |
| 555 | |
| 556 | runBenchmarks(benchmarks, |
| 557 | iterations, |
| 558 | 250, |
| 559 | osrm, |
| 560 | gpsTraces, |
| 561 | [](int iteration, |
| 562 | const Benchmark &benchmark, |
| 563 | const OSRM &osrm, |
| 564 | const GPSTraces &gpsTraces, |
| 565 | Statistics &statistics) |
| 566 | { |
| 567 | engine::api::ResultT result = json::Object(); |
| 568 | TableParameters params; |
| 569 | |
| 570 | for (size_t i = 0; i < benchmark.coordinates; ++i) |
| 571 | { |
| 572 | params.coordinates.push_back(gpsTraces.getRandomCoordinate()); |
| 573 | } |
| 574 | |
| 575 | TIMER_START(table); |
| 576 | const auto rc = osrm.Table(params, result); |
| 577 | TIMER_STOP(table); |
| 578 | |
| 579 | statistics.push(TIMER_MSEC(table), iteration); |
| 580 | |
| 581 | auto &json_result = std::get<json::Object>(result); |
| 582 | if (rc != Status::Ok || !json_result.values.contains("durations")) |
| 583 | { |
| 584 | auto code = std::get<json::String>(json_result.values["code"]).value; |
| 585 | if (code != "NoSegment") |
| 586 | { |
| 587 | throw std::runtime_error{"Couldn't compute table"}; |
| 588 | } |
| 589 | } |
| 590 | }); |
| 591 | } |
| 592 | |
| 593 | } // namespace |
| 594 |
no test coverage detected