def test_performance_cache(self):
"""Compare the naive vanilla python lazy property
(where property is written in C in the python stdlib)
with our IRP lazy_property with the genealogy overhead
Python 2.*: 1.25x Python 3.*: 1.75x
"""
import timeit
i = timeit.timeit('f.b0;', setup='from __main__ import BigTree; f = BigTree()', number=5000000)
h = timeit.timeit('f.b0_vlp;', setup='from __main__ import BigTree; f = BigTree()', number=5000000)
try:
self.assertTrue(i < h*1.75)
except AssertionError as e:
raise e
评论列表
文章目录