Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Test: time_relight using a human-built structure and using natural te…

…rrain.
  • Loading branch information...
commit 0d22baea91cdb95ba01f7fc1e2615bbee4afbe32 1 parent 4569227
@codewarrior0 codewarrior0 authored
View
29 test/time_relight.py
@@ -1,13 +1,36 @@
+from infiniteworld import MCInfdevOldLevel
import mclevel
from timeit import timeit
+from test import templevel
+
#import logging
#logging.basicConfig(level=logging.INFO)
-path = "testfiles\\AnvilWorld"
-world = mclevel.fromFile(path)
+def natural_relight():
+ world = mclevel.fromFile("testfiles/AnvilWorld")
+ t = timeit(lambda: world.generateLights(world.allChunks), number=1)
+ print "Relight natural terrain: %d chunks in %.02f seconds (%.02fms per chunk)" % (world.chunkCount, t, t / world.chunkCount * 1000)
+
+
+def manmade_relight():
+ t = templevel.TempLevel("TimeRelight", createFunc=lambda f:MCInfdevOldLevel(f, create=True))
+
+ world = t.level
+ station = mclevel.fromFile("testfiles/station.schematic")
+
+ times = 2
+
+ for x in range(times):
+ for z in range(times):
+ world.copyBlocksFrom(station, station.bounds, (x * station.Width, 63, z * station.Length), create=True)
+
+ t = timeit(lambda: world.generateLights(world.allChunks), number=1)
+ print "Relight manmade building: %d chunks in %.02f seconds (%.02fms per chunk)" % (world.chunkCount, t, t / world.chunkCount * 1000)
-print "Relight: %d chunks in %.02f seconds" % (world.chunkCount, timeit(lambda: world.generateLights(world.allChunks), number=1))
+if __name__ == '__main__':
+ natural_relight()
+ manmade_relight()
View
BIN  testfiles/Station.schematic
Binary file not shown
View
3  testfiles/station.txt
@@ -0,0 +1,3 @@
+station.schematic downloaded from http://www.mcschematics.com/index.php?topic=14331.msg91903
+
+Credit goes to the author, bas_de_paljas.
Please sign in to comment.
Something went wrong with that request. Please try again.