Example #1
0
    def test_simple_size_estimation(self, space, i):
        class_node = ClassNode(i)
        assert class_node.size_estimate() == 0

        for j in range(1000):
            w_obj = FakeObject(class_node)
            for a in "abcdefghij"[:i]:
                w_obj.map.add_attr(space, w_obj, a)
        assert class_node.size_estimate() == i
Example #2
0
    def test_avg_size_estimation(self, space, i):
        class_node = ClassNode(i)
        assert class_node.size_estimate() == 0

        for j in range(1000):
            w_obj = FakeObject(class_node)
            for a in "abcdefghij"[:i]:
                w_obj.map.add_attr(space, w_obj, a)
            w_obj = FakeObject(class_node)
            for a in "klmnopqars":
                w_obj.map.add_attr(space, w_obj, a)
        assert class_node.size_estimate() in [(i + 10) // 2, (i + 11) // 2]