Files
test2/tests/performance/tests/animation.py
Campbell Barton c434782e3a File headers: SPDX License migration
Use a shorter/simpler license convention, stops the header taking so
much space.

Follow the SPDX license specification: https://spdx.org/licenses

- C/C++/objc/objc++
- Python
- Shell Scripts
- CMake, GNUmakefile

While most of the source tree has been included

- `./extern/` was left out.
- `./intern/cycles` & `./intern/atomic` are also excluded because they
  use different header conventions.

doc/license/SPDX-license-identifiers.txt has been added to list SPDX all
used identifiers.

See P2788 for the script that automated these edits.

Reviewed By: brecht, mont29, sergey

Ref D14069
2022-02-11 09:14:36 +11:00

48 lines
1.0 KiB
Python

# SPDX-License-Identifier: Apache-2.0
import api
import os
def _run(args):
import bpy
import time
start_time = time.time()
elapsed_time = 0.0
num_frames = 0
while elapsed_time < 10.0:
scene = bpy.context.scene
for i in range(scene.frame_start, scene.frame_end + 1):
scene.frame_set(i)
num_frames += scene.frame_end + 1 - scene.frame_start
elapsed_time = time.time() - start_time
time_per_frame = elapsed_time / num_frames
result = {'time': time_per_frame}
return result
class AnimationTest(api.Test):
def __init__(self, filepath):
self.filepath = filepath
def name(self):
return self.filepath.stem
def category(self):
return "animation"
def run(self, env, device_id):
args = {}
result, _ = env.run_in_blender(_run, args, [self.filepath])
return result
def generate(env):
filepaths = env.find_blend_files('animation/*')
return [AnimationTest(filepath) for filepath in filepaths]