MCPcopy Create free account
hub / github.com/Project-OSRM/osrm-backend / runTableBenchmark

Function runTableBenchmark

src/benchmarks/bench.cpp:544–591  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

542 });
543}
544void 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

Callers 1

mainFunction · 0.85

Calls 7

runBenchmarksFunction · 0.85
getRandomCoordinateMethod · 0.80
pushMethod · 0.80
containsMethod · 0.80
ObjectClass · 0.50
push_backMethod · 0.45
TableMethod · 0.45

Tested by

no test coverage detected