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
This commit is contained in:
Sean Kim
2025-06-10 16:30:42 -07:00
committed by Gitea
parent c8d0e76ebd
commit 339abe76d0

View File

@@ -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()