Exemplo n.º 1
0
def natural_relight():
    world = bench_temp_level("AnvilWorld")
    dim = world.getDimension()
    positions = []
    for cx, cz in dim.chunkPositions():
        chunk = dim.getChunk(cx, cz)
        for cy in chunk.sectionPositions():
            positions.append((cx, cy, cz))

    poses = iter(positions)

    def do_relight():
        cx, cy, cz = poses.next()
        indices = numpy.indices((16, 16, 16), numpy.int32)
        indices.shape = 3, 16*16*16
        indices += ([cx << 4], [cy << 4], [cz << 4])
        x, y, z = indices

        relight.updateLightsByCoord(dim, x, y, z)

    # Find out how many sections we can do in `maxtime` seconds.
    start = time.time()
    count = 0
    maxtime = 10
    end = start + maxtime
    while time.time() < end:
        try:
            do_relight()
        except StopIteration:
            break
        count += 1
    t = time.time() - start

    print "Relight natural terrain: %d/%d chunk-sections in %.02f seconds (%f sections per second; %dms per section)" % (count, len(positions), t, count / t, 1000 * t / count)
Exemplo n.º 2
0
        def perSection():
            world = bench_temp_level("AnvilWorld")
            dim = world.getDimension()

            start = time.time()
            do_copy(dim, station, "section")
            t = time.time() - start - copyTime

            print "Relight manmade building (in copyBlocks, for each section): " \
                  "%d chunk-sections in %.02f seconds (%f sections per second; %dms per section)" \
                  % (len(positions), t, len(positions) / t, 1000 * t / len(positions))
Exemplo n.º 3
0
def timeFillCeiling():
    temp = bench_temp_level("AnvilWorld")
    editor = temp
    dim = editor.getDimension()
    bounds = dim.bounds
    x, y, z = bounds.center
    y = 254
    x -= size//2
    z -= size//2
    bounds = BoundingBox((x, y, z), (size, 1, size))
    exhaust(dim.fillBlocksIter(bounds, editor.blocktypes["planks"]))
Exemplo n.º 4
0
def timeFillCeiling():
    temp = bench_temp_level("AnvilWorld")
    editor = temp
    dim = editor.getDimension()
    bounds = dim.bounds
    x, y, z = bounds.center
    y = 254
    x -= size // 2
    z -= size // 2
    bounds = BoundingBox((x, y, z), (size, 1, size))
    exhaust(dim.fillBlocksIter(bounds, editor.blocktypes["planks"]))
Exemplo n.º 5
0
def timeFill():
    temp = bench_temp_level("AnvilWorld")
    editor = temp
    dim = editor.getDimension()
    editor.loadedChunkLimit = 1
    exhaust(dim.fillBlocksIter(dim.bounds, editor.blocktypes.OakWoodPlanks))
Exemplo n.º 6
0
from benchmarks import bench_temp_level
from mceditlib.export import extractSchematicFrom

level = bench_temp_level("AnvilWorld")
schem = None

def timeExport():
    global schem
    schem = extractSchematicFrom(level, level.bounds)

def timeImport():
    level.getDimension().copyBlocks(schem, schem.bounds, (0, 0, 0))
#
#import zlib
#import regionfile
#
#compresslevel = 1
#def _deflate(data):
#    return zlib.compress(data, compresslevel)
#
#regionfile.deflate = _deflate

if __name__ == "__main__":
    import timeit
    #timeExport()
    #timeImport()
    print "Exported in %.02f" % (timeit.timeit(timeExport, number=1))
    print "Imported in %.02f" % (timeit.timeit(timeImport, number=1))
Exemplo n.º 7
0
def manmade_relight(test):
    world = bench_temp_level("AnvilWorld")
    dim = world.getDimension()
    stationEditor = WorldEditor("test_files/station.schematic")
    station = stationEditor.getDimension()

    startCopy = time.time()
    box = do_copy(dim, station, False)
    copyTime = time.time() - startCopy
    print("Copy took %f seconds. Reducing relight-in-copyBlocks times by this much." % copyTime)

    positions = []
    for cx, cz in box.chunkPositions():
        for cy in box.sectionPositions(cx, cz):
            positions.append((cx, cy, cz))
    assert len(positions) > box.chunkCount

    if test == "post" or test == "all":
        def postCopy():  # profiling
            start = time.time()
            count = 0
            print("Relighting outside of copyBlocks. Updating %d cells" % (len(positions) * 16 * 16 * 16))
            for cx, cy, cz in positions:
                indices = numpy.indices((16, 16, 16), numpy.int32)
                indices.shape = 3, 16*16*16
                indices += ([cx << 4], [cy << 4], [cz << 4])
                x, y, z = indices
                relight.updateLightsByCoord(dim, x, y, z)
                count += 1
            t = time.time() - start

            print "Relight manmade building (outside copyBlocks): " \
                  "%d (out of %d) chunk-sections in %.02f seconds (%f sections per second; %dms per section)" \
                  % (count, len(positions), t, count / t, 1000 * t / count)
        postCopy()

    if test == "smart" or test == "all":
        def allSections():
            world = bench_temp_level("AnvilWorld")
            dim = world.getDimension()

            start = time.time()
            do_copy(dim, station, "all")
            t = time.time() - start - copyTime

            print "Relight manmade building (in copyBlocks, all sections): " \
                  "%d chunk-sections in %.02f seconds (%f sections per second; %dms per section)" \
                  % (len(positions), t, len(positions) / t, 1000 * t / len(positions))
        allSections()

    if test == "section" or test == "all":
        def perSection():
            world = bench_temp_level("AnvilWorld")
            dim = world.getDimension()

            start = time.time()
            do_copy(dim, station, "section")
            t = time.time() - start - copyTime

            print "Relight manmade building (in copyBlocks, for each section): " \
                  "%d chunk-sections in %.02f seconds (%f sections per second; %dms per section)" \
                  % (len(positions), t, len(positions) / t, 1000 * t / len(positions))
        perSection()
Exemplo n.º 8
0
from benchmarks import bench_temp_level
from mceditlib.export import extractSchematicFrom

level = bench_temp_level("AnvilWorld")
schem = None


def timeExport():
    global schem
    schem = extractSchematicFrom(level, level.bounds)


def timeImport():
    level.getDimension().copyBlocks(schem, schem.bounds, (0, 0, 0))


#
#import zlib
#import regionfile
#
#compresslevel = 1
#def _deflate(data):
#    return zlib.compress(data, compresslevel)
#
#regionfile.deflate = _deflate

if __name__ == "__main__":
    import timeit
    #timeExport()
    #timeImport()
    print "Exported in %.02f" % (timeit.timeit(timeExport, number=1))
Exemplo n.º 9
0
def timeFill():
    temp = bench_temp_level("AnvilWorld")
    editor = temp
    dim = editor.getDimension()
    editor.loadedChunkLimit = 1
    exhaust(dim.fillBlocksIter(dim.bounds, editor.blocktypes.OakWoodPlanks))
Exemplo n.º 10
0
        #     print("Referrers:\n%s" % refs)
        #     print("WorldEditor: _loadedChunks: %d (_pending_removals: %d)" % (lc, len(editor._loadedChunks._pending_removals)))
    print("[Tile]Entities: ", ents)

def saveall():
    for cPos in pos[cStart:cEnd]:
        dim.getChunk(*cPos).dirty = True
    editor.saveChanges()

import sys
if len(sys.argv) > 1:
    filename = sys.argv[1]
else:
    filename = "AnvilWorld_1.8"

editor = bench_temp_level(filename)
dim = editor.getDimension()


cStart = 0
cEnd = 10000
chunkCount = cEnd - cStart

pos = list(dim.chunkPositions())

loadTime = timeit.timeit(loadall, number=1)
print("Loaded %d chunks in %.02fms (%f cps)" % (chunkCount, loadTime * 1000, chunkCount/loadTime))
print("Cache hits: %d, misses: %d, rejects: %d, max rejects: %d, queue: %d" % (
    editor._chunkDataCache.hits, editor._chunkDataCache.misses,
    editor._chunkDataCache.rejects, editor._chunkDataCache.max_rejects,
    len(editor._chunkDataCache.queue)))
Exemplo n.º 11
0
    print("[Tile]Entities: ", ents)


def saveall():
    for cPos in pos[cStart:cEnd]:
        dim.getChunk(*cPos).dirty = True
    editor.saveChanges()


import sys
if len(sys.argv) > 1:
    filename = sys.argv[1]
else:
    filename = "AnvilWorld_1.8"

editor = bench_temp_level(filename)
dim = editor.getDimension()

cStart = 0
cEnd = 10000
chunkCount = cEnd - cStart

pos = list(dim.chunkPositions())

loadTime = timeit.timeit(loadall, number=1)
print("Loaded %d chunks in %.02fms (%f cps)" %
      (chunkCount, loadTime * 1000, chunkCount / loadTime))
print("Cache hits: %d, misses: %d, rejects: %d, max rejects: %d, queue: %d" %
      (editor._chunkDataCache.hits, editor._chunkDataCache.misses,
       editor._chunkDataCache.rejects, editor._chunkDataCache.max_rejects,
       len(editor._chunkDataCache.queue)))