From ca6911cb6e120410333f800cde6de992411d9b17 Mon Sep 17 00:00:00 2001 From: cmdupuis3 Date: Mon, 6 Jul 2026 13:51:00 -0500 Subject: [PATCH 1/4] Connectivity benchmark sketches --- benchmarks/bench_connectivity.py | 68 ++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 benchmarks/bench_connectivity.py diff --git a/benchmarks/bench_connectivity.py b/benchmarks/bench_connectivity.py new file mode 100644 index 000000000..1891d61fe --- /dev/null +++ b/benchmarks/bench_connectivity.py @@ -0,0 +1,68 @@ +import os +import urllib.request +from pathlib import Path + +import uxarray as ux + +current_path = Path(os.path.dirname(os.path.realpath(__file__))) + +data_var = 'bottomDepth' + +grid_filename_480 = "oQU480.grid.nc" +data_filename_480 = "oQU480.data.nc" + +grid_filename_120 = "oQU120.grid.nc" +data_filename_120 = "oQU120.data.nc" + +filenames = [grid_filename_480, data_filename_480, grid_filename_120, data_filename_120] + +for filename in filenames: + if not os.path.isfile(current_path / filename): + # downloads the files from Cookbook repo, if they haven't been downloaded locally yet + url = f"https://github.com/ProjectPythia/unstructured-grid-viz-cookbook/raw/main/meshfiles/{filename}" + _, headers = urllib.request.urlretrieve(url, filename=current_path / filename) + + +file_path_dict = {"480km": [current_path / grid_filename_480, current_path / data_filename_480], + "120km": [current_path / grid_filename_120, current_path / data_filename_120]} + +class GridBenchmark: + """Class used as a template for benchmarks requiring a ``Grid`` in this + module across both resolutions.""" + param_names = ['resolution', ] + params = [['480km', '120km'], ] + + def setup(self, resolution, *args, **kwargs): + self.uxgrid = ux.open_grid(file_path_dict[resolution][0]) + + def teardown(self, resolution, *args, **kwargs): + del self.uxgrid + +class Connectivity(GridBenchmark): + + def time_face_node(self): + _ = self.uxgrid.face_node_connectivity + + def time_edge_node(self): + _ = self.uxgrid.edge_node_connectivity + + def time_node_node(self): + _ = self.uxgrid.node_node_connectivity + + def time_face_edge(self): + _ = self.uxgrid.face_edge_connectivity + + def time_edge_edge(self): + _ = self.uxgrid.edge_edge_connectivity + + def time_node_edge(self): + _ = self.uxgrid.node_edge_connectivity + + def time_face_face(self): + _ = self.uxgrid.face_face_connectivity + + def time_edge_face(self): + _ = self.uxgrid.edge_face_connectivity + + def time_node_face(self): + _ = self.uxgrid.node_face_connectivity From b9a00325cf7ec8c3d7fe91f94646f32f579eee69 Mon Sep 17 00:00:00 2001 From: cmdupuis3 Date: Mon, 6 Jul 2026 14:03:48 -0500 Subject: [PATCH 2/4] Connectivity benchmarks --- benchmarks/bench_connectivity.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/benchmarks/bench_connectivity.py b/benchmarks/bench_connectivity.py index 1891d61fe..4fc6f0645 100644 --- a/benchmarks/bench_connectivity.py +++ b/benchmarks/bench_connectivity.py @@ -40,29 +40,31 @@ def teardown(self, resolution, *args, **kwargs): class Connectivity(GridBenchmark): - def time_face_node(self): + def time_face_node(self, resolution): _ = self.uxgrid.face_node_connectivity - def time_edge_node(self): + def time_edge_node(self, resolution): _ = self.uxgrid.edge_node_connectivity - def time_node_node(self): - _ = self.uxgrid.node_node_connectivity +# TODO: Not yet supported? +# def time_node_node(self, resolution): +# _ = self.uxgrid.node_node_connectivity - def time_face_edge(self): + def time_face_edge(self, resolution): _ = self.uxgrid.face_edge_connectivity - def time_edge_edge(self): - _ = self.uxgrid.edge_edge_connectivity +# TODO: Not yet supported? +# def time_edge_edge(self, resolution): +# _ = self.uxgrid.edge_edge_connectivity - def time_node_edge(self): + def time_node_edge(self, resolution): _ = self.uxgrid.node_edge_connectivity - def time_face_face(self): + def time_face_face(self, resolution): _ = self.uxgrid.face_face_connectivity - def time_edge_face(self): + def time_edge_face(self, resolution): _ = self.uxgrid.edge_face_connectivity - def time_node_face(self): + def time_node_face(self, resolution): _ = self.uxgrid.node_face_connectivity From e98d73169b79ba77eacb583bed0b6c051f3e3af6 Mon Sep 17 00:00:00 2001 From: cmdupuis3 Date: Mon, 6 Jul 2026 14:43:30 -0500 Subject: [PATCH 3/4] Connectivity benchmarks: add larger grids --- benchmarks/bench_connectivity.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/benchmarks/bench_connectivity.py b/benchmarks/bench_connectivity.py index 4fc6f0645..2bbbfd549 100644 --- a/benchmarks/bench_connectivity.py +++ b/benchmarks/bench_connectivity.py @@ -22,15 +22,23 @@ url = f"https://github.com/ProjectPythia/unstructured-grid-viz-cookbook/raw/main/meshfiles/{filename}" _, headers = urllib.request.urlretrieve(url, filename=current_path / filename) +# Paths to grid files on Glade +dyamond_path_dict = {"30km": "/glade/campaign/cisl/vast/uxarray/data/dyamond/30km/grid.nc", + "15km": "/glade/campaign/cisl/vast/uxarray/data/dyamond/15km/grid.nc", + "7.5km": "/glade/campaign/cisl/vast/uxarray/data/dyamond/7.5km/grid.nc", + "3.75km": "/glade/campaign/cisl/vast/uxarray/data/dyamond/3.75km/grid.nc"} -file_path_dict = {"480km": [current_path / grid_filename_480, current_path / data_filename_480], +oQU_path_dict = {"480km": [current_path / grid_filename_480, current_path / data_filename_480], "120km": [current_path / grid_filename_120, current_path / data_filename_120]} +file_path_dict = oQU_path_dict | dyamond_path_dict + + class GridBenchmark: """Class used as a template for benchmarks requiring a ``Grid`` in this module across both resolutions.""" param_names = ['resolution', ] - params = [['480km', '120km'], ] + params = [['480km', '120km', '30km', '15km', '7.5km', '3.75km'], ] def setup(self, resolution, *args, **kwargs): self.uxgrid = ux.open_grid(file_path_dict[resolution][0]) @@ -54,7 +62,7 @@ def time_face_edge(self, resolution): _ = self.uxgrid.face_edge_connectivity # TODO: Not yet supported? -# def time_edge_edge(self, resolution): +# def time_edge_edge(self, resolution): # _ = self.uxgrid.edge_edge_connectivity def time_node_edge(self, resolution): From 89175a923d78535cc39c095a22e696345c684af0 Mon Sep 17 00:00:00 2001 From: cmdupuis3 Date: Tue, 7 Jul 2026 10:52:28 -0500 Subject: [PATCH 4/4] Connectivity benchmarks: fix paths by removing unneeded data file references. --- benchmarks/bench_connectivity.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/benchmarks/bench_connectivity.py b/benchmarks/bench_connectivity.py index 2bbbfd549..4deee0811 100644 --- a/benchmarks/bench_connectivity.py +++ b/benchmarks/bench_connectivity.py @@ -6,15 +6,9 @@ current_path = Path(os.path.dirname(os.path.realpath(__file__))) -data_var = 'bottomDepth' - grid_filename_480 = "oQU480.grid.nc" -data_filename_480 = "oQU480.data.nc" - grid_filename_120 = "oQU120.grid.nc" -data_filename_120 = "oQU120.data.nc" - -filenames = [grid_filename_480, data_filename_480, grid_filename_120, data_filename_120] +filenames = [grid_filename_480, grid_filename_120] for filename in filenames: if not os.path.isfile(current_path / filename): @@ -22,15 +16,15 @@ url = f"https://github.com/ProjectPythia/unstructured-grid-viz-cookbook/raw/main/meshfiles/{filename}" _, headers = urllib.request.urlretrieve(url, filename=current_path / filename) +oQU_path_dict = {"480km": current_path / grid_filename_480, + "120km": current_path / grid_filename_120} + # Paths to grid files on Glade dyamond_path_dict = {"30km": "/glade/campaign/cisl/vast/uxarray/data/dyamond/30km/grid.nc", "15km": "/glade/campaign/cisl/vast/uxarray/data/dyamond/15km/grid.nc", "7.5km": "/glade/campaign/cisl/vast/uxarray/data/dyamond/7.5km/grid.nc", "3.75km": "/glade/campaign/cisl/vast/uxarray/data/dyamond/3.75km/grid.nc"} -oQU_path_dict = {"480km": [current_path / grid_filename_480, current_path / data_filename_480], - "120km": [current_path / grid_filename_120, current_path / data_filename_120]} - file_path_dict = oQU_path_dict | dyamond_path_dict @@ -41,7 +35,7 @@ class GridBenchmark: params = [['480km', '120km', '30km', '15km', '7.5km', '3.75km'], ] def setup(self, resolution, *args, **kwargs): - self.uxgrid = ux.open_grid(file_path_dict[resolution][0]) + self.uxgrid = ux.open_grid(file_path_dict[resolution]) def teardown(self, resolution, *args, **kwargs): del self.uxgrid