Optimise R-tree queries in the case if there is no need to limit maximum number of results
This commit is contained in:
parent
fc4fa10346
commit
85d95aff54
@ -1,11 +1,9 @@
|
|||||||
#ifndef OSRM_UTIL_RECTANGLE_HPP
|
#ifndef OSRM_UTIL_RECTANGLE_HPP
|
||||||
#define OSRM_UTIL_RECTANGLE_HPP
|
#define OSRM_UTIL_RECTANGLE_HPP
|
||||||
|
|
||||||
#include "coordinate.hpp"
|
|
||||||
#include "util/coordinate.hpp"
|
#include "util/coordinate.hpp"
|
||||||
#include "util/coordinate_calculation.hpp"
|
#include "util/coordinate_calculation.hpp"
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
#include <boost/math/constants/constants.hpp>
|
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
@ -220,11 +220,14 @@ try
|
|||||||
params.radiuses.emplace_back();
|
params.radiuses.emplace_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto run_benchmark = [&](double radiusInMeters)
|
auto run_benchmark = [&](std::optional<double> radiusInMeters)
|
||||||
|
{
|
||||||
|
if (radiusInMeters)
|
||||||
{
|
{
|
||||||
for (auto &radius : params.radiuses)
|
for (auto &radius : params.radiuses)
|
||||||
{
|
{
|
||||||
radius = radiusInMeters;
|
radius = *radiusInMeters;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TIMER_START(routes);
|
TIMER_START(routes);
|
||||||
@ -241,25 +244,25 @@ try
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
TIMER_STOP(routes);
|
TIMER_STOP(routes);
|
||||||
std::cout << "Radius " << radiusInMeters << "m: " << std::endl;
|
if (radiusInMeters)
|
||||||
|
{
|
||||||
|
std::cout << "Radius " << *radiusInMeters << "m: " << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "Default radius: " << std::endl;
|
||||||
|
}
|
||||||
std::cout << (TIMER_MSEC(routes) / NUM) << "ms/req at " << params.coordinates.size()
|
std::cout << (TIMER_MSEC(routes) / NUM) << "ms/req at " << params.coordinates.size()
|
||||||
<< " coordinate" << std::endl;
|
<< " coordinate" << std::endl;
|
||||||
std::cout << (TIMER_MSEC(routes) / NUM / params.coordinates.size()) << "ms/coordinate"
|
std::cout << (TIMER_MSEC(routes) / NUM / params.coordinates.size()) << "ms/coordinate"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
};
|
};
|
||||||
|
|
||||||
try
|
run_benchmark(std::nullopt);
|
||||||
{
|
|
||||||
run_benchmark(5.0);
|
run_benchmark(5.0);
|
||||||
run_benchmark(10.0);
|
run_benchmark(10.0);
|
||||||
run_benchmark(15.0);
|
run_benchmark(15.0);
|
||||||
run_benchmark(30.0);
|
run_benchmark(30.0);
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
std::cerr << "Error: " << e.what() << std::endl;
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user