Add benchmark for SelectionScene

This commit is contained in:
David Vierra 2015-01-11 13:11:11 -10:00
parent 52b7261837
commit 3d8e524186

View File

@ -0,0 +1,28 @@
"""
time_selectionrender
"""
from __future__ import absolute_import, division, print_function
import logging
import timeit
from PySide import QtGui
from mcedit2.rendering.selection import SelectionScene
from mceditlib.selection import ShapedSelection, SphereShape
from mceditlib.selection import BoundingBox
log = logging.getLogger(__name__)
def main():
app = QtGui.QApplication([])
selection = ShapedSelection(BoundingBox((0, 0, 0), (63, 63, 63)), SphereShape)
scene = SelectionScene()
def timeBuild():
scene.selection = selection
for _ in scene.loadSections():
pass
duration = timeit.timeit(timeBuild, number=1) * 1000
print("timeBuild x1 in %0.2fms (%0.3fms per chunk)" % (duration, duration / selection.chunkCount))
if __name__ == '__main__':
main()