Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: speedup engine #14

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
max-parallel: 4
matrix:
platform: [ubuntu-latest]
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -67,18 +67,28 @@ jobs:
env:
PLATFORM: ${{ matrix.platform }}
- name: Coveralls
uses: AndreMiras/coveralls-python-action@develop
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: ${{ matrix.test-name }}
COVERALLS_PARALLEL: true
run: |
coveralls --service=github

coveralls_finish:
needs: [test]
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: AndreMiras/coveralls-python-action@develop
- name: Set up Python
uses: actions/setup-python@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true

python-version: 3.8.5
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install coveralls
- name: Coveralls Finished
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pip3 install --upgrade coveralls
coveralls --service=github --finish
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

* performance enhancement by avoiding revalidating all nodes/edges over and over again

## [0.7.1] - 2022-02-04

### Changed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Simple routing engine for OpenStreetMaps with easy to customize profiles/weight-

## Requirements

* Python 3.6.1 or newer
* Python 3.7 or newer

## Installation

Expand Down
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()
Loading