Skip to content

Commit

Permalink
chore: add benchmark suite to evauluate perfomance of route finding
Browse files Browse the repository at this point in the history
  • Loading branch information
escaped committed May 20, 2022
1 parent 77d984a commit 31d4e24
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -369,3 +369,4 @@ $RECYCLE.BIN/

# End of https://www.toptal.com/developers/gitignore/api/vim,osx,node,linux,python,windows,visualstudiocode,git

.asv
22 changes: 22 additions & 0 deletions asv.conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"version": 1,
"project": "routor",
"project_url": "https://github.com/routeco/routor",

"repo": ".",
"environment_type": "virtualenv",


"install_command": ["in-dir={env_dir} python -mpip install {wheel_file}"],
"uninstall_command": ["return-code=any python -mpip uninstall -y {project}"],
"build_command": ["python -mpip install poetry", "PIP_NO_BUILD_ISOLATION=false python -mpip wheel --no-deps --no-index -w {build_cache_dir} {build_dir}"],

"branches": ["main"],
"show_commit_url": "https://github.com/routeco/routor/commit/",

"benchmark_dir": "benchmarks",

"env_dir": ".asv/env",
"results_dir": ".asv/results",
"html_dir": ".asv/html"
}
Empty file added benchmarks/__init__.py
Empty file.
40 changes: 40 additions & 0 deletions benchmarks/benchmarks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from pathlib import Path

from routor import weights
from routor.engine import Engine
from routor.models import Location
from routor.utils import graph as graph_utils

MAP_PATH = Path(".").absolute() / "benchmark_map.graphml"


class TimeSuite:
def setup_cache(self):
graph = graph_utils.download_map(
["bristol"],
node_tags=["osmid"],
edge_tags=["junction", "traffic_signals", "surface", "lanes"],
api_key=None,
)
graph_utils.save_map(graph, MAP_PATH)

def setup(self):
self.engine = Engine(MAP_PATH)

def time_load_map(self):
Engine(MAP_PATH)

def time_routing(self):
origin = Location(longitude=-2.583160400390625, latitude=51.43806566801884)
destination = Location(
longitude=-2.6348304748535156, latitude=51.48223813101211
)
self.engine.route(origin, destination, weights.length, weights.travel_time)


if __name__ == "__main__":
suite = TimeSuite()
suite.setup_cache()
suite.setup()

suite.time_routing()

0 comments on commit 31d4e24

Please sign in to comment.