Source

yt.geometry_tests / test_handler.py

Full commit
from yt.mods import *
from yt.geometry.selection_routines import \
    SphereSelector

#pf = load("output_00700/info_00700.txt")
#pf = load("output_00007/info_00007.txt")
pf = load("output_00045/info_00045.txt")
pf.h

class SphereMock(object):
    center = [0.5, 0.5, 0.5]
    radius = 0.1

N = 1
ss = SphereMock()
sobj = SphereSelector(ss)
t1 = time.time()
for i in range(N):
    mask = sobj.select_octs(pf.h.oct_handler)
t2 = time.time()
print mask.sum(), mask.size
print "Percent", mask.sum() / float(mask.size)
print "%0.3e %0.3e" % (t2-t1, (t2-t1)/float(N))

t1 = time.time()
for i in range(10):
    count = pf.h.oct_handler.count(mask, split = False)
t2 = time.time()
print "To count: %0.3e" % ((t2-t1)/10)
#inds = pf.h.oct_handler.indices(mask)
t1 = time.time()
for i in range(10):
    count = pf.h.oct_handler.count(mask, split = True)
t2 = time.time()
print "To select: %0.3e" % ((t2-t1)/10)

dd = pf.h.all_data()
t1 = time.time()
pf.h._identify_base_chunk(dd)
t2 = time.time()
print "To count and whatnot %0.3e" % (t2-t1)
ii = pf.h._chunk_all(dd)
chunk = ii.next()

t1 = time.time()
ic = chunk.icoords
t2 = time.time()
print "To coordinatize: %0.3e" % (t2-t1)