From e43ecca01627393d0aabe56c2087d87938aed6c3 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 20 Sep 2021 18:44:52 +0200 Subject: [PATCH] Tests: measure time per frame in animation performance benchmark Instead of a fixed number of frames, so that benchmarking takes about the same time on any machine. --- tests/performance/tests/animation.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tests/performance/tests/animation.py b/tests/performance/tests/animation.py index 1a92f1a9718..c1a5c77860f 100644 --- a/tests/performance/tests/animation.py +++ b/tests/performance/tests/animation.py @@ -9,14 +9,20 @@ def _run(args): import time start_time = time.time() + elapsed_time = 0.0 + num_frames = 0 - scene = bpy.context.scene - for i in range(scene.frame_start, scene.frame_end): - scene.frame_set(scene.frame_start) + while elapsed_time < 10.0: + scene = bpy.context.scene + for i in range(scene.frame_start, scene.frame_end + 1): + scene.frame_set(i) - elapsed_time = time.time() - start_time + num_frames += scene.frame_end + 1 - scene.frame_start + elapsed_time = time.time() - start_time - result = {'time': elapsed_time} + time_per_frame = elapsed_time / num_frames + + result = {'time': time_per_frame} return result @@ -32,10 +38,10 @@ class AnimationTest(api.Test): def run(self, env, device_id): args = {} - result, _ = env.run_in_blender(_run, args) + result, _ = env.run_in_blender(_run, args, [self.filepath]) return result def generate(env): - filepaths = env.find_blend_files('animation') + filepaths = env.find_blend_files('animation/*') return [AnimationTest(filepath) for filepath in filepaths]