diff --git a/rust/sedona-raster-functions/Cargo.toml b/rust/sedona-raster-functions/Cargo.toml index 3eedf1605..2a1e9ca90 100644 --- a/rust/sedona-raster-functions/Cargo.toml +++ b/rust/sedona-raster-functions/Cargo.toml @@ -50,4 +50,20 @@ rstest = { workspace = true } [[bench]] harness = false -name = "native-raster-functions" +name = "simple_functions" + +[[bench]] +harness = false +name = "rs_geotransform" + +[[bench]] +harness = false +name = "rs_rastercoordinate" + +[[bench]] +harness = false +name = "rs_srid" + +[[bench]] +harness = false +name = "rs_worldcoordinate" diff --git a/rust/sedona-raster-functions/benches/rs_geotransform.rs b/rust/sedona-raster-functions/benches/rs_geotransform.rs new file mode 100644 index 000000000..0dc394bd5 --- /dev/null +++ b/rust/sedona-raster-functions/benches/rs_geotransform.rs @@ -0,0 +1,40 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use criterion::{criterion_group, criterion_main, Criterion}; +use sedona_testing::benchmark_util::{benchmark, BenchmarkArgSpec::*}; + +fn criterion_benchmark(c: &mut Criterion) { + let f = sedona_raster_functions::register::default_function_set(); + + let func_names = [ + "rs_rotation", + "rs_scalex", + "rs_scaley", + "rs_skewx", + "rs_skewy", + "rs_upperleftx", + "rs_upperlefty", + ]; + + for func_name in func_names { + benchmark::scalar(c, &f, "rs_geotransform", func_name, Raster(64, 64)); + } +} + +criterion_group!(benches, criterion_benchmark); +criterion_main!(benches); diff --git a/rust/sedona-raster-functions/benches/native-raster-functions.rs b/rust/sedona-raster-functions/benches/rs_rastercoordinate.rs similarity index 53% rename from rust/sedona-raster-functions/benches/native-raster-functions.rs rename to rust/sedona-raster-functions/benches/rs_rastercoordinate.rs index cb4cb7305..72d33640f 100644 --- a/rust/sedona-raster-functions/benches/native-raster-functions.rs +++ b/rust/sedona-raster-functions/benches/rs_rastercoordinate.rs @@ -14,49 +14,18 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. + use criterion::{criterion_group, criterion_main, Criterion}; use sedona_testing::benchmark_util::{benchmark, BenchmarkArgSpec::*, BenchmarkArgs}; fn criterion_benchmark(c: &mut Criterion) { let f = sedona_raster_functions::register::default_function_set(); - benchmark::scalar(c, &f, "native-raster", "rs_crs", Raster(64, 64)); - benchmark::scalar(c, &f, "native-raster", "rs_envelope", Raster(64, 64)); - benchmark::scalar(c, &f, "native-raster", "rs_height", Raster(64, 64)); - benchmark::scalar( - c, - &f, - "native-raster", - "rs_rastertoworldcoord", - BenchmarkArgs::ArrayScalarScalar(Raster(64, 64), Int32(0, 63), Int32(0, 63)), - ); + // RS_WorldToRasterCoord(raster, x, y) benchmark::scalar( c, &f, - "native-raster", - "rs_rastertoworldcoordx", - BenchmarkArgs::ArrayScalarScalar(Raster(64, 64), Int32(0, 63), Int32(0, 63)), - ); - benchmark::scalar( - c, - &f, - "native-raster", - "rs_rastertoworldcoordy", - BenchmarkArgs::ArrayScalarScalar(Raster(64, 64), Int32(0, 63), Int32(0, 63)), - ); - benchmark::scalar(c, &f, "native-raster", "rs_rotation", Raster(64, 64)); - benchmark::scalar(c, &f, "native-raster", "rs_scalex", Raster(64, 64)); - benchmark::scalar(c, &f, "native-raster", "rs_scaley", Raster(64, 64)); - benchmark::scalar(c, &f, "native-raster", "rs_skewx", Raster(64, 64)); - benchmark::scalar(c, &f, "native-raster", "rs_skewy", Raster(64, 64)); - benchmark::scalar(c, &f, "native-raster", "rs_srid", Raster(64, 64)); - benchmark::scalar(c, &f, "native-raster", "rs_upperleftx", Raster(64, 64)); - benchmark::scalar(c, &f, "native-raster", "rs_upperlefty", Raster(64, 64)); - benchmark::scalar(c, &f, "native-raster", "rs_width", Raster(64, 64)); - benchmark::scalar( - c, - &f, - "native-raster", + "rs_rastercoordinate", "rs_worldtorastercoord", BenchmarkArgs::ArrayScalarScalar( Raster(64, 64), @@ -64,10 +33,12 @@ fn criterion_benchmark(c: &mut Criterion) { Float64(-45.0, 45.0), ), ); + + // RS_WorldToRasterCoordX(raster, x, y) benchmark::scalar( c, &f, - "native-raster", + "rs_rastercoordinate", "rs_worldtorastercoordx", BenchmarkArgs::ArrayScalarScalar( Raster(64, 64), @@ -75,10 +46,12 @@ fn criterion_benchmark(c: &mut Criterion) { Float64(-45.0, 45.0), ), ); + + // RS_WorldToRasterCoordY(raster, x, y) benchmark::scalar( c, &f, - "native-raster", + "rs_rastercoordinate", "rs_worldtorastercoordy", BenchmarkArgs::ArrayScalarScalar( Raster(64, 64), diff --git a/rust/sedona-raster-functions/benches/rs_srid.rs b/rust/sedona-raster-functions/benches/rs_srid.rs new file mode 100644 index 000000000..2bc37c75c --- /dev/null +++ b/rust/sedona-raster-functions/benches/rs_srid.rs @@ -0,0 +1,32 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use criterion::{criterion_group, criterion_main, Criterion}; +use sedona_testing::benchmark_util::{benchmark, BenchmarkArgSpec::*}; + +fn criterion_benchmark(c: &mut Criterion) { + let f = sedona_raster_functions::register::default_function_set(); + + // RS_SRID(raster) + benchmark::scalar(c, &f, "rs_srid", "rs_srid", Raster(64, 64)); + + // RS_CRS(raster) + benchmark::scalar(c, &f, "rs_srid", "rs_crs", Raster(64, 64)); +} + +criterion_group!(benches, criterion_benchmark); +criterion_main!(benches); diff --git a/rust/sedona-raster-functions/benches/rs_worldcoordinate.rs b/rust/sedona-raster-functions/benches/rs_worldcoordinate.rs new file mode 100644 index 000000000..8d1c0ceaa --- /dev/null +++ b/rust/sedona-raster-functions/benches/rs_worldcoordinate.rs @@ -0,0 +1,53 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use criterion::{criterion_group, criterion_main, Criterion}; +use sedona_testing::benchmark_util::{benchmark, BenchmarkArgSpec::*, BenchmarkArgs}; + +fn criterion_benchmark(c: &mut Criterion) { + let f = sedona_raster_functions::register::default_function_set(); + + // RS_RasterToWorldCoord(raster, colX, rowY) + benchmark::scalar( + c, + &f, + "rs_worldcoordinate", + "rs_rastertoworldcoord", + BenchmarkArgs::ArrayScalarScalar(Raster(64, 64), Int32(0, 63), Int32(0, 63)), + ); + + // RS_RasterToWorldCoordX(raster, colX, rowY) + benchmark::scalar( + c, + &f, + "rs_worldcoordinate", + "rs_rastertoworldcoordx", + BenchmarkArgs::ArrayScalarScalar(Raster(64, 64), Int32(0, 63), Int32(0, 63)), + ); + + // RS_RasterToWorldCoordY(raster, colX, rowY) + benchmark::scalar( + c, + &f, + "rs_worldcoordinate", + "rs_rastertoworldcoordy", + BenchmarkArgs::ArrayScalarScalar(Raster(64, 64), Int32(0, 63), Int32(0, 63)), + ); +} + +criterion_group!(benches, criterion_benchmark); +criterion_main!(benches); diff --git a/rust/sedona-raster-functions/benches/simple_functions.rs b/rust/sedona-raster-functions/benches/simple_functions.rs new file mode 100644 index 000000000..e9ba67813 --- /dev/null +++ b/rust/sedona-raster-functions/benches/simple_functions.rs @@ -0,0 +1,29 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use criterion::{criterion_group, criterion_main, Criterion}; +use sedona_testing::benchmark_util::{benchmark, BenchmarkArgSpec::*}; + +fn criterion_benchmark(c: &mut Criterion) { + let f = sedona_raster_functions::register::default_function_set(); + benchmark::scalar(c, &f, "simple-functions", "rs_envelope", Raster(64, 64)); + benchmark::scalar(c, &f, "simple-functions", "rs_width", Raster(64, 64)); + benchmark::scalar(c, &f, "simple-functions", "rs_height", Raster(64, 64)); +} + +criterion_group!(benches, criterion_benchmark); +criterion_main!(benches);