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
This commit is contained in:
Habib Gahbiche
2025-08-08 14:28:21 +02:00
parent 24c4e0a3f7
commit 8d078be86b

View File

@@ -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]