Skip to content

Commit

Permalink
return lookup timing
Browse files Browse the repository at this point in the history
  • Loading branch information
felixguendling committed Dec 2, 2024
1 parent 478bed2 commit 797230e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
14 changes: 13 additions & 1 deletion include/osr/routing/route.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,19 @@ struct path {
template <typename Profile>
dijkstra<Profile>& get_dijkstra();

std::vector<std::optional<path>> route(
struct one_to_many_result {
one_to_many_result(std::chrono::milliseconds&& lookup_time,
std::vector<std::optional<path>>&& paths)
: lookup_time_{lookup_time}, paths_{std::move(paths)} {}

one_to_many_result(std::vector<std::optional<path>>&& paths)
: paths_{std::move(paths)} {}

std::chrono::milliseconds lookup_time_{};
std::vector<std::optional<path>> paths_;
};

one_to_many_result route(
ways const&,
lookup const&,
search_profile,
Expand Down
16 changes: 11 additions & 5 deletions src/route.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -387,7 +388,7 @@ std::vector<std::optional<path>> route(
return result;
}

std::vector<std::optional<path>> route(
one_to_many_result route(
ways const& w,
lookup const& l,
search_profile const profile,
Expand All @@ -399,8 +400,9 @@ std::vector<std::optional<path>> route(
bitvec<node_idx_t> const* blocked,
sharing_data const* sharing,
std::function<bool(path const&)> const& do_reconstruct) {
auto const r = [&]<typename Profile>(
dijkstra<Profile>& d) -> std::vector<std::optional<path>> {
auto const r =
[&]<typename Profile>(dijkstra<Profile>& d) -> one_to_many_result {
UTL_START_TIMING(lookup);
auto const from_match =
l.match<Profile>(from, false, dir, max_match_distance, blocked);
if (from_match.empty()) {
Expand All @@ -409,8 +411,12 @@ std::vector<std::optional<path>> route(
auto const to_match = utl::to_vec(to, [&](auto&& x) {
return l.match<Profile>(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<std::chrono::milliseconds>(lookup_stop -
lookup_start),
route(w, d, from, to, from_match, to_match, max, dir, blocked, sharing,
do_reconstruct)};
};

switch (profile) {
Expand Down

0 comments on commit 797230e

Please sign in to comment.