-
Notifications
You must be signed in to change notification settings - Fork 14
bench script + fixed python bench #123
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
base: main
Are you sure you want to change the base?
Changes from all commits
0e2736e
ac44cd8
02f22c5
764b6b0
a6fb415
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| [project] | ||
| name = "geo-index-benches" | ||
| version = "0.1.0" | ||
| description = "Add your description here" | ||
| readme = "README.md" | ||
| dependencies = [ | ||
| "geoindex-rs", | ||
| "geopandas", | ||
| "pyogrio", | ||
| "pyarrow", | ||
| "numpy", | ||
| "requests", | ||
| "shapely", | ||
| ] | ||
|
|
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer using a basic |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| geoindex-rs | ||
| geopandas | ||
| pyogrio | ||
| pyarrow | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you're also missing |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import geopandas as gpd | ||
| import numpy as np | ||
| import shapely | ||
| from geoindex_rs import rtree as rt | ||
| import timeit | ||
| import pyogrio | ||
| import requests | ||
| def load_data(): | ||
| path = "./bench_data/nz-building-outlines.parquet" | ||
| gdf = gpd.read_parquet(path) | ||
| wgs84_gdf = gdf.to_crs("epsg:4326") | ||
| bounds = wgs84_gdf.bounds | ||
| print(bounds) | ||
| return bounds | ||
|
|
||
|
|
||
| def construct_wsg84_tree(bounds): | ||
| builder = rt.RTreeBuilder(bounds.shape[0]) | ||
| min_x= np.array(bounds["minx"].values) | ||
| min_y=np.array(bounds["miny"].values) | ||
| max_x=np.array(bounds["maxx"].values) | ||
| max_y=np.array(bounds["maxy"].values) | ||
| builder.add(min_x, min_y, max_x, max_y) | ||
| return builder.finish() | ||
|
|
||
| def construct_shapely_tree(bounds): | ||
| tree = shapely.SRTree(bounds.shape[0]) | ||
| return tree | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| bounds = load_data() | ||
|
|
||
| time = timeit.timeit(stmt='construct_wsg84_tree(bounds)', number=100, | ||
| globals=globals()) | ||
| print(f"Rtree time: {time:.2f} seconds for 100 iterations") | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| #!/bin/bash | ||
| mkdir -p ./benches/bench_data | ||
| cd ./benches/bench_data | ||
| if [ ! -f "Utah.geojson.zip" ] | ||
| then | ||
| echo "Downloading geojson benchmark data..." | ||
| wget https://minedbuildings.z5.web.core.windows.net/legacy/usbuildings-v2/Utah.geojson.zip | ||
| else | ||
| echo "Benchmark data already downloaded" | ||
| fi | ||
| if [ ! -f "Utah.geojson" ] | ||
| then | ||
| echo "Unzipping Utah.geojson.zip.." | ||
| unzip Utah.geojson.zip | ||
| else | ||
| echo "Utah.geojson already unzipped " | ||
| fi | ||
|
|
||
| if [ ! -f "nz-building-outlines.parquet" ] | ||
| then | ||
| echo "Downloading parquet benchmark data..." | ||
| wget https://storage.googleapis.com/open-geodata/linz-examples/nz-building-outlines.parquet | ||
| else | ||
| echo "Parquet Benchmark data already downloaded" | ||
| fi | ||
|
|
||
|
|
||
| cd ../ | ||
| uv venv | ||
| source .venv/bin/activate | ||
| uv pip install -r pyproject.toml | ||
| uv run generate_data.py | ||
| cd ../ | ||
| echo "Running base benchmarks..." | ||
| cargo bench --bench rtree | ||
| echo "Running benchmarks with rayon feature..." | ||
| cargo bench --bench rtree --features rayon | ||
| cd ./benches | ||
| uv run rtree.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is from https://github.com/microsoft/USBuildingFootprints#download-links, with a download link (unsure if this is persistent) of https://minedbuildings.z5.web.core.windows.net/legacy/usbuildings-v2/Utah.geojson.zip