Paste P460

D113 speed test
ActivePublic

Authored by Alexander Romanov (a.romanov) on Apr 5 2017, 5:27 PM.
Tags
None
Subscribers
None
1# Apache License, Version 2.0
2
3# ./blender.bin --background -noaudio --python tests/python/bl_pyapi_idprop_datablock_speed.py -- --verbose
4import bpy
5import unittest
6import time
7
8# change to False for the build without D113
9patched = True
10# number of datablock pointer properties
11nprops = 10
12
13class TestCreationRemoving(unittest.TestCase):
14
15def test_objects_creation(self):
16desc = "- %s_props\n" % nprops
17if not patched:
18desc = "- not_patched\n"
19dup_report = "Object duplication:\n%s" % desc
20rem_report = "Object removal:\n%s" % desc
21undo_report = "Undo removal:\n%s" % desc
22
23for n in range(50, 1000, 50):
24bpy.ops.wm.read_homefile()
25if patched:
26for i in range(0, nprops):
27bpy.data.objects["Cube"]["prop%s" % i] = bpy.data.objects['Camera']
28start = time.time()
29for i in range(0, n):
30ob = bpy.data.objects["Cube"].copy()
31bpy.context.scene.objects.link(ob)
32end = time.time()
33dup_report +="%s %s\n" % (n, end - start)
34
35bpy.ops.ed.undo_push()
36start = time.time()
37for o in bpy.data.objects:
38bpy.data.objects.remove(o, do_unlink = True)
39end = time.time()
40rem_report += "%s %s\n" % (n, end - start)
41
42start = time.time()
43bpy.ops.ed.undo()
44end = time.time()
45undo_report += "%s %s\n" % (n, end - start)
46
47print(dup_report)
48print(rem_report)
49print(undo_report)
50
51
52if __name__ == '__main__':
53import sys
54sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [])
55unittest.main()