diff --git a/test/time_relight.py b/test/time_relight.py index 30e29a8..17c8cf3 100644 --- a/test/time_relight.py +++ b/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) -print "Relight: %d chunks in %.02f seconds" % (world.chunkCount, timeit(lambda: world.generateLights(world.allChunks), number=1)) + +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) + +if __name__ == '__main__': + natural_relight() + manmade_relight() diff --git a/testfiles/Station.schematic b/testfiles/Station.schematic new file mode 100644 index 0000000..1f3b3ac Binary files /dev/null and b/testfiles/Station.schematic differ diff --git a/testfiles/station.txt b/testfiles/station.txt new file mode 100644 index 0000000..21fb322 --- /dev/null +++ b/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.