diff --git a/tests/performance/tests/compositor.py b/tests/performance/tests/compositor.py new file mode 100644 index 00000000000..f61d52de5d5 --- /dev/null +++ b/tests/performance/tests/compositor.py @@ -0,0 +1,63 @@ +# SPDX-FileCopyrightText: 2025 Blender Authors +# +# SPDX-License-Identifier: Apache-2.0 + +import api + + +def _run(args): + import bpy + import time + + device_type, _ = (args['device_type'].split("-") + [""])[:2] + scene = bpy.context.scene + scene.render.compositor_device = ('CPU' if device_type == 'CPU' else 'GPU') + + test_time_start = time.time() + measured_times = [] + + min_measurements = 5 + max_measurements = 100 + timeout = 10 + + while True: + start_time = time.time() + bpy.ops.render.render() + elapsed_time = time.time() - start_time + measured_times.append(elapsed_time) + + if len(measured_times) >= min_measurements and test_time_start + timeout < time.time(): + break + if len(measured_times) >= max_measurements: + break + + average_time = sum(measured_times) / len(measured_times) + result = {'time': average_time} + return result + + +class CompositorTest(api.Test): + def __init__(self, filepath): + self.filepath = filepath + + def name(self): + return self.filepath.stem + + def category(self): + return "compositor" + + def use_device(self): + return True + + def run(self, env, device_id): + tokens = device_id.split('_') + device_type = tokens[0] + args = {'device_type': device_type} + + result, _ = env.run_in_blender(_run, args, [self.filepath]) + return result + + +def generate(env): + filepaths = env.find_blend_files('compositor/*') + return [CompositorTest(filepath) for filepath in filepaths]