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

Function main

src/benchmarks/bench.cpp:595–660  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

593} // namespace
594
595int main(int argc, const char *argv[])
596try
597{
598 if (argc < 6)
599 {
600 std::cerr << "Usage: " << argv[0]
601 << " data.osrm <mld|ch> <path to GPS traces.csv> "
602 "<route|match|trip|table|nearest> <number_of_iterations>\n";
603 return EXIT_FAILURE;
604 }
605
606 // Configure based on a .osrm base path, and no datasets in shared mem from osrm-datastore
607 EngineConfig config;
608 config.storage_config = {argv[1]};
609 config.algorithm =
610 std::string{argv[2]} == "mld" ? EngineConfig::Algorithm::MLD : EngineConfig::Algorithm::CH;
611 config.use_shared_memory = false;
612
613 // Routing machine with several services (such as Route, Table, Nearest, Trip, Match)
614 OSRM osrm{config};
615
616 GPSTraces gpsTraces{42};
617 gpsTraces.readCSV(argv[3]);
618
619 int iterations = std::stoi(argv[5]);
620
621 const auto benchmarkToRun = std::string{argv[4]};
622
623 if (benchmarkToRun == "route")
624 {
625 runRouteBenchmark(osrm, gpsTraces, iterations);
626 }
627 else if (benchmarkToRun == "match")
628 {
629 runMatchBenchmark(osrm, gpsTraces, iterations);
630 }
631 else if (benchmarkToRun == "nearest")
632 {
633 runNearestBenchmark(osrm, gpsTraces, iterations);
634 }
635 else if (benchmarkToRun == "trip")
636 {
637 runTripBenchmark(osrm, gpsTraces, iterations);
638 }
639 else if (benchmarkToRun == "table")
640 {
641 runTableBenchmark(osrm, gpsTraces, iterations);
642 }
643 else
644 {
645 std::cerr << "Unknown benchmark: " << benchmarkToRun << std::endl;
646 return EXIT_FAILURE;
647 }
648
649 std::cout << "Peak RAM: " << std::setprecision(3)
650 << static_cast<double>(osrm::util::PeakRAMUsedInBytes()) /
651 static_cast<double>((1024 * 1024))
652 << "MB" << std::endl;

Callers

nothing calls this directly

Calls 8

runRouteBenchmarkFunction · 0.85
runMatchBenchmarkFunction · 0.85
runNearestBenchmarkFunction · 0.85
runTripBenchmarkFunction · 0.85
runTableBenchmarkFunction · 0.85
PeakRAMUsedInBytesFunction · 0.85
readCSVMethod · 0.80
whatMethod · 0.80

Tested by

no test coverage detected