From 339abe76d04e4cbf15cf2e5ed2657e3a8cf2549e Mon Sep 17 00:00:00 2001 From: Sean Kim Date: Tue, 10 Jun 2025 16:30:42 -0700 Subject: [PATCH] Tests: Reset sculpt performance test state between every run Prior to this commit, the sculpt scene and object was only initialized once, at the very beginning of the test. This has the downside of slowly changing the performance characteristics as more and more strokes are performed, as the number of vertices within a given stroke may eventually approach 1. To ensure a consistent measurement each time, rebuild the scene between each brush stroke. Pull Request: https://projects.blender.org/blender/blender/pulls/139960 --- tests/performance/tests/sculpt.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/tests/performance/tests/sculpt.py b/tests/performance/tests/sculpt.py index 4eab4fcd302..47540e65cf0 100644 --- a/tests/performance/tests/sculpt.py +++ b/tests/performance/tests/sculpt.py @@ -159,23 +159,22 @@ def _run_brush_test(args: dict): import time context = bpy.context - timeout = 5 + timeout = 10 total_time_start = time.time() # Create an undo stack explicitly. This isn't created by default in background mode. bpy.ops.ed.undo_push() - prepare_sculpt_scene(context, args['mode']) prepare_brush(context, args['brush_type']) - context_override = context.copy() - set_view3d_context_override(context_override) - min_measurements = 5 max_measurements = 100 measurements = [] while True: + prepare_sculpt_scene(context, args['mode']) + context_override = context.copy() + set_view3d_context_override(context_override) with context.temp_override(**context_override): start = time.time() bpy.ops.sculpt.brush_stroke(stroke=generate_stroke(context_override), override_location=True) @@ -194,22 +193,20 @@ def _run_bvh_test(args: dict): import time context = bpy.context - timeout = 5 + timeout = 10 total_time_start = time.time() # Create an undo stack explicitly. This isn't created by default in background mode. bpy.ops.ed.undo_push() - prepare_sculpt_scene(context, args['mode']) - - context_override = context.copy() - set_view3d_context_override(context_override) - min_measurements = 5 max_measurements = 100 measurements = [] while True: + prepare_sculpt_scene(context, args['mode']) + context_override = context.copy() + set_view3d_context_override(context_override) with context.temp_override(**context_override): start = time.time() bpy.ops.sculpt.optimize()