def test_copy_pointer(self, schema, benchmark):
# this is similar to test_struct, but the struct we set has a very
# deep structure, which means that we are effectively measuring the
# performance of copy_pointer
if schema.__name__ not in ('Capnpy', 'PyCapnp'):
pytest.skip('N/A')
#
#self._make_big_tree() # uncomment this if you want to regenerate the file
s = self.BIG_TREE.read("rb")
tree = schema.Tree.loads(s)
def loop(oldtree):
for i in range(1000):
new_tree = schema.Tree(oldtree.root)
return new_tree
new_tree = benchmark(loop, tree)
assert new_tree.root.x == 9999
评论列表
文章目录