Skip to content

Commit c51a2b8

Browse files
committed
benchmarks: save mean n_steps instead of last n_steps
1 parent 48bd3b7 commit c51a2b8

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

benchmarks/benchmark_surface_flow.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,18 @@ def test_benchmark_surface_flow_n_steps(benchmark, num_cells, cell_size, n_steps
133133
@pytest.mark.parametrize("n_seconds", [30]) # Set as parameter to get it in the output json
134134
def test_benchmark_surface_flow_n_seconds(benchmark, num_cells, cell_size, n_seconds):
135135
"""Run the benchmark for a given number of cells and cell size"""
136+
results = []
137+
def wrapper(eggbox_sim, n_seconds):
138+
n_steps = benchmark_surface_flow_n_seconds(eggbox_sim, n_seconds)
139+
results.append(n_steps)
140+
return n_steps
141+
136142
eggbox_sim = setup_eggbox_simulation(num_cells=num_cells, cell_size=cell_size)
137-
n_steps = benchmark(benchmark_surface_flow_n_seconds, eggbox_sim, n_seconds)
138-
print(f"Number of steps: {n_steps}")
139-
benchmark.extra_info["n_steps"] = n_steps
140-
benchmark.extra_info["lattice_updates"] = n_steps * num_cells
143+
n_steps = benchmark(wrapper, eggbox_sim, n_seconds)
144+
# Calculate statistics
145+
n_steps_mean = np.mean(results)
146+
n_steps_std = np.std(results)
147+
print(f"Number of steps: {n_steps} (mean: {n_steps_mean:.1f} ± {n_steps_std:.1f})")
148+
benchmark.extra_info["n_steps_mean"] = n_steps_mean
149+
benchmark.extra_info["n_steps_std"] = n_steps_std
150+
benchmark.extra_info["lattice_updates"] = n_steps_mean * num_cells

0 commit comments

Comments
 (0)