diff --git a/include/osr/routing/route.h b/include/osr/routing/route.h index c475ae7..20cfaff 100644 --- a/include/osr/routing/route.h +++ b/include/osr/routing/route.h @@ -42,7 +42,19 @@ struct path { template dijkstra& get_dijkstra(); -std::vector> route( +struct one_to_many_result { + one_to_many_result(std::chrono::milliseconds&& lookup_time, + std::vector>&& paths) + : lookup_time_{lookup_time}, paths_{std::move(paths)} {} + + one_to_many_result(std::vector>&& paths) + : paths_{std::move(paths)} {} + + std::chrono::milliseconds lookup_time_{}; + std::vector> paths_; +}; + +one_to_many_result route( ways const&, lookup const&, search_profile, diff --git a/src/route.cc b/src/route.cc index ce4759b..64ea7f2 100644 --- a/src/route.cc +++ b/src/route.cc @@ -3,6 +3,7 @@ #include "boost/thread/tss.hpp" #include "utl/concat.h" +#include "utl/timing.h" #include "utl/to_vec.h" #include "utl/verify.h" @@ -387,7 +388,7 @@ std::vector> route( return result; } -std::vector> route( +one_to_many_result route( ways const& w, lookup const& l, search_profile const profile, @@ -399,8 +400,9 @@ std::vector> route( bitvec const* blocked, sharing_data const* sharing, std::function const& do_reconstruct) { - auto const r = [&]( - dijkstra& d) -> std::vector> { + auto const r = + [&](dijkstra& d) -> one_to_many_result { + UTL_START_TIMING(lookup); auto const from_match = l.match(from, false, dir, max_match_distance, blocked); if (from_match.empty()) { @@ -409,8 +411,12 @@ std::vector> route( auto const to_match = utl::to_vec(to, [&](auto&& x) { return l.match(x, true, dir, max_match_distance, blocked); }); - return route(w, d, from, to, from_match, to_match, max, dir, blocked, - sharing, do_reconstruct); + UTL_STOP_TIMING(lookup); + return one_to_many_result{ + std::chrono::duration_cast(lookup_stop - + lookup_start), + route(w, d, from, to, from_match, to_match, max, dir, blocked, sharing, + do_reconstruct)}; }; switch (profile) {