Skip to content

Commit e45d6f9

Browse files
authored
feat: Add ST_Azimuth benchmark and update benchmarking docs (#188)
1 parent 21b8227 commit e45d6f9

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

benchmarks/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,16 @@ The below commands assume your working directory is in `benchmarks`.
3636
cd benchmarks/
3737
```
3838

39+
Please also make sure you have PostGIS running. Instructions for starting PostGIS using the provided docker image can be found in the [contributors-guide](../docs/contributors-guide.md)
40+
3941
To run a benchmark, simply run the corresponding test function. For example, to run the benchmarks for st_buffer, you can run
4042

4143
```bash
4244
pytest test_functions.py::TestBenchFunctions::test_st_buffer
4345
```
4446

47+
Note: It is recommended to run a single (pytest) benchmark function at a time instead of the whole suite because these benchmarks take a long time. This is because they run multiple iterations by default. For example, it often takes 2-3 minutes to run a single benchmark for a basic function.
48+
4549
Most of the time, you'll also want to group by `param:table` or `func` (function) by using the `--benchmark-group-by=param:table` flag. pytest-benchmark will highlight the "best" value in green (e.g fastest for median, lowest for stddev) and "worse" value in red for each column per each group.
4650

4751
```bash

benchmarks/test_bench_base.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ def setup_class(self):
2828

2929
# Setup tables
3030
for name, base_options in [
31+
(
32+
"points_simple",
33+
{
34+
"geom_type": "Point",
35+
"target_rows": num_geoms,
36+
},
37+
),
3138
(
3239
"segments_large",
3340
{

benchmarks/test_functions.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,21 @@ def queries():
3636

3737
benchmark(queries)
3838

39+
@pytest.mark.parametrize("eng", [SedonaDB, PostGIS, DuckDB])
40+
@pytest.mark.parametrize(
41+
"table",
42+
[
43+
"points_simple",
44+
],
45+
)
46+
def test_st_azimuth(self, benchmark, eng, table):
47+
eng = self._get_eng(eng)
48+
49+
def queries():
50+
eng.execute_and_collect(f"SELECT ST_Azimuth(geom1, geom2) from {table}")
51+
52+
benchmark(queries)
53+
3954
@pytest.mark.parametrize("eng", [SedonaDB, PostGIS, DuckDB])
4055
@pytest.mark.parametrize(
4156
"table",

0 commit comments

Comments
 (0)