Files
test2/tests/performance/tests/blend_load.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

43 lines
926 B
Python

# SPDX-License-Identifier: Apache-2.0
import api
import os
import pathlib
def _run(filepath):
import bpy
import time
# Load once to ensure it's cached by OS
bpy.ops.wm.open_mainfile(filepath=filepath)
bpy.ops.wm.read_homefile()
# Measure loading the second time
start_time = time.time()
bpy.ops.wm.open_mainfile(filepath=filepath)
elapsed_time = time.time() - start_time
result = {'time': elapsed_time}
return result
class BlendLoadTest(api.Test):
def __init__(self, filepath):
self.filepath = filepath
def name(self):
return self.filepath.stem
def category(self):
return "blend_load"
def run(self, env, device_id):
result, _ = env.run_in_blender(_run, str(self.filepath))
return result
def generate(env):
filepaths = env.find_blend_files('*/*')
return [BlendLoadTest(filepath) for filepath in filepaths]