From 8d078be86bf3c3bc6aad9ae82179f26eb0c3bdaa Mon Sep 17 00:00:00 2001 From: Habib Gahbiche Date: Fri, 8 Aug 2025 14:28:21 +0200 Subject: [PATCH] Benchmark: Compositor support Extend the existing benchmark framework to support the compositor. Files are added separately. Example output: ``` $ ./benchmark.py run comp 4.5 main ghosts 1.2055s 1.0243s ghosts 1.4936s 1.0454s ghosts 0.4414s 0.4330s file:///Users/habib/blender-git/benchmark/comp/results.html ``` Pull Request: https://projects.blender.org/blender/blender/pulls/136600 --- tests/performance/tests/compositor.py | 63 +++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 tests/performance/tests/compositor.py 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]