1616from iris .experimental .ugrid .utils import recombine_submeshes
1717
1818from .. import TrackAddedMemoryAllocation , on_demand_benchmark
19- from ..generate_data .ugrid import make_cube_like_2d_cubesphere
19+ from ..generate_data .ugrid import BENCHMARK_DATA , make_cube_like_2d_cubesphere
2020
2121
2222class Mixin :
2323 # Characterise time taken + memory-allocated, for various stages of combine
2424 # operations on cubesphere-like test data.
25- timeout = 180 .0
25+ timeout = 300 .0
2626 params = [100 , 200 , 300 , 500 , 1000 , 1668 ]
2727 param_names = ["cubesphere_C<N>" ]
2828 # Fix result units for the tracking benchmarks.
2929 unit = "Mb"
30+ temp_save_path = BENCHMARK_DATA / "tmp.nc"
3031
3132 def _parametrised_cache_filename (self , n_cubesphere , content_name ):
32- return f"cube_C{ n_cubesphere } _{ content_name } .nc"
33+ return BENCHMARK_DATA / f"cube_C{ n_cubesphere } _{ content_name } .nc"
3334
3435 def _make_region_cubes (self , full_mesh_cube ):
3536 """Make a fixed number of region cubes from a full meshcube."""
@@ -139,6 +140,9 @@ def setup(
139140 # Fix dask usage mode for all the subsequent performance tests.
140141 self .fix_dask_settings ()
141142
143+ def teardown (self , _ ):
144+ self .temp_save_path .unlink (missing_ok = True )
145+
142146 def fix_dask_settings (self ):
143147 """
144148 Fix "standard" dask behaviour for time+space testing.
@@ -165,6 +169,9 @@ def recombine(self):
165169 )
166170 return result
167171
172+ def save_recombined_cube (self ):
173+ save (self .recombined_cube , self .temp_save_path )
174+
168175
169176@on_demand_benchmark
170177class CreateCube (Mixin ):
@@ -215,15 +222,15 @@ class SaveData(Mixin):
215222
216223 def time_save (self , n_cubesphere ):
217224 # Save to disk, which must compute data + stream it to file.
218- save ( self .recombined_cube , "tmp.nc" )
225+ self .save_recombined_cube ( )
219226
220227 @TrackAddedMemoryAllocation .decorator ()
221228 def track_addedmem_save (self , n_cubesphere ):
222- save ( self .recombined_cube , "tmp.nc" )
229+ self .save_recombined_cube ( )
223230
224231 def track_filesize_saved (self , n_cubesphere ):
225- save ( self .recombined_cube , "tmp.nc" )
226- return os . path . getsize ( "tmp.nc" ) * 1.0e-6
232+ self .save_recombined_cube ( )
233+ return self . temp_save_path . stat (). st_size * 1.0e-6
227234
228235
229236@on_demand_benchmark
@@ -243,8 +250,8 @@ def setup(
243250
244251 def time_stream_file2file (self , n_cubesphere ):
245252 # Save to disk, which must compute data + stream it to file.
246- save ( self .recombined_cube , "tmp.nc" )
253+ self .save_recombined_cube ( )
247254
248255 @TrackAddedMemoryAllocation .decorator ()
249256 def track_addedmem_stream_file2file (self , n_cubesphere ):
250- save ( self .recombined_cube , "tmp.nc" )
257+ self .save_recombined_cube ( )
0 commit comments