Page MenuHome
Paste P460

D113 speed test
ActivePublic

Authored by Alexander Romanov (a.romanov) on Apr 5 2017, 5:27 PM.
# Apache License, Version 2.0
# ./blender.bin --background -noaudio --python tests/python/bl_pyapi_idprop_datablock_speed.py -- --verbose
import bpy
import unittest
import time
# change to False for the build without D113
patched = True
# number of datablock pointer properties
nprops = 10
class TestCreationRemoving(unittest.TestCase):
def test_objects_creation(self):
desc = "- %s_props\n" % nprops
if not patched:
desc = "- not_patched\n"
dup_report = "Object duplication:\n%s" % desc
rem_report = "Object removal:\n%s" % desc
undo_report = "Undo removal:\n%s" % desc
for n in range(50, 1000, 50):
bpy.ops.wm.read_homefile()
if patched:
for i in range(0, nprops):
bpy.data.objects["Cube"]["prop%s" % i] = bpy.data.objects['Camera']
start = time.time()
for i in range(0, n):
ob = bpy.data.objects["Cube"].copy()
bpy.context.scene.objects.link(ob)
end = time.time()
dup_report +="%s %s\n" % (n, end - start)
bpy.ops.ed.undo_push()
start = time.time()
for o in bpy.data.objects:
bpy.data.objects.remove(o, do_unlink = True)
end = time.time()
rem_report += "%s %s\n" % (n, end - start)
start = time.time()
bpy.ops.ed.undo()
end = time.time()
undo_report += "%s %s\n" % (n, end - start)
print(dup_report)
print(rem_report)
print(undo_report)
if __name__ == '__main__':
import sys
sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [])
unittest.main()