test_ctor.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:capnpy 作者: antocuni 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号