From 7e68169dd47e38e105c304d0bb967f5639e76b9b Mon Sep 17 00:00:00 2001 From: Aaron Zedwick <95507181+aaronzedwick@users.noreply.github.com> Date: Wed, 31 Jul 2024 17:33:03 -0500 Subject: [PATCH] ASV Benchmarks for Remapping and Tree Construction (#870) * Added initial benchmarks * Updated remapping benchmarks, up down sampling --------- Co-authored-by: Philip Chmielowiec <67855069+philipc2@users.noreply.github.com> --- benchmarks/mpas_ocean.py | 49 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/benchmarks/mpas_ocean.py b/benchmarks/mpas_ocean.py index cd1840d82..d2baaf86b 100644 --- a/benchmarks/mpas_ocean.py +++ b/benchmarks/mpas_ocean.py @@ -115,3 +115,52 @@ def teardown(self, resolution, periodic_elements): def time_dataarray_to_polycollection(self, resolution, periodic_elements): self.uxds[data_var].to_polycollection() + + +class ConstructTreeStructures: + param_names = ['resolution'] + params = ['480km', '120km'] + + def setup(self, resolution): + self.uxds = ux.open_dataset(file_path_dict[resolution][0], file_path_dict[resolution][1]) + + def teardown(self, resolution): + del self.uxds + + def time_kd_tree(self, resolution): + self.uxds.uxgrid.get_kd_tree() + + def time_ball_tree(self, resolution): + self.uxds.uxgrid.get_ball_tree() + + +class RemapDownsample: + + def setup(self): + self.uxds_120 = ux.open_dataset(file_path_dict['120km'][0], file_path_dict['120km'][1]) + self.uxds_480 = ux.open_dataset(file_path_dict['480km'][0], file_path_dict['480km'][1]) + + def teardown(self): + del self.uxds_120, self.uxds_480 + + def time_nearest_neighbor_remapping(self): + self.uxds_120["bottomDepth"].remap.nearest_neighbor(self.uxds_480.uxgrid) + + def time_inverse_distance_weighted_remapping(self): + self.uxds_120["bottomDepth"].remap.inverse_distance_weighted(self.uxds_480.uxgrid) + + +class RemapUpsample: + + def setup(self): + self.uxds_120 = ux.open_dataset(file_path_dict['120km'][0], file_path_dict['120km'][1]) + self.uxds_480 = ux.open_dataset(file_path_dict['480km'][0], file_path_dict['480km'][1]) + + def teardown(self): + del self.uxds_120, self.uxds_480 + + def time_nearest_neighbor_remapping(self): + self.uxds_480["bottomDepth"].remap.nearest_neighbor(self.uxds_120.uxgrid) + + def time_inverse_distance_weighted_remapping(self): + self.uxds_480["bottomDepth"].remap.inverse_distance_weighted(self.uxds_120.uxgrid)