This is an automated email from the ASF dual-hosted git repository.
jiayu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/sedona-db.git
The following commit(s) were added to refs/heads/main by this push:
new e45d6f9 feat: Add ST_Azimuth benchmark and update benchmarking docs
(#188)
e45d6f9 is described below
commit e45d6f9a145be216e4fa62408a51aa9b22a0d14e
Author: Peter Nguyen <[email protected]>
AuthorDate: Mon Oct 6 21:24:55 2025 -0700
feat: Add ST_Azimuth benchmark and update benchmarking docs (#188)
---
benchmarks/README.md | 4 ++++
benchmarks/test_bench_base.py | 7 +++++++
benchmarks/test_functions.py | 15 +++++++++++++++
3 files changed, 26 insertions(+)
diff --git a/benchmarks/README.md b/benchmarks/README.md
index 6d6633b..c84b0ab 100644
--- a/benchmarks/README.md
+++ b/benchmarks/README.md
@@ -36,12 +36,16 @@ The below commands assume your working directory is in
`benchmarks`.
cd benchmarks/
```
+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)
+
To run a benchmark, simply run the corresponding test function. For example,
to run the benchmarks for st_buffer, you can run
```bash
pytest test_functions.py::TestBenchFunctions::test_st_buffer
```
+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.
+
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.
```bash
diff --git a/benchmarks/test_bench_base.py b/benchmarks/test_bench_base.py
index 2c8061d..8f01274 100644
--- a/benchmarks/test_bench_base.py
+++ b/benchmarks/test_bench_base.py
@@ -28,6 +28,13 @@ class TestBenchBase:
# Setup tables
for name, base_options in [
+ (
+ "points_simple",
+ {
+ "geom_type": "Point",
+ "target_rows": num_geoms,
+ },
+ ),
(
"segments_large",
{
diff --git a/benchmarks/test_functions.py b/benchmarks/test_functions.py
index 6d5c33b..01d34e1 100644
--- a/benchmarks/test_functions.py
+++ b/benchmarks/test_functions.py
@@ -36,6 +36,21 @@ class TestBenchFunctions(TestBenchBase):
benchmark(queries)
+ @pytest.mark.parametrize("eng", [SedonaDB, PostGIS, DuckDB])
+ @pytest.mark.parametrize(
+ "table",
+ [
+ "points_simple",
+ ],
+ )
+ def test_st_azimuth(self, benchmark, eng, table):
+ eng = self._get_eng(eng)
+
+ def queries():
+ eng.execute_and_collect(f"SELECT ST_Azimuth(geom1, geom2) from
{table}")
+
+ benchmark(queries)
+
@pytest.mark.parametrize("eng", [SedonaDB, PostGIS, DuckDB])
@pytest.mark.parametrize(
"table",