def test_memory_usage(self):
for o in self.objs:
res = o.memory_usage()
res_deep = o.memory_usage(deep=True)
if (com.is_object_dtype(o) or (isinstance(o, Series) and
com.is_object_dtype(o.index))):
# if there are objects, only deep will pick them up
self.assertTrue(res_deep > res)
else:
self.assertEqual(res, res_deep)
if isinstance(o, Series):
self.assertEqual(
(o.memory_usage(index=False) +
o.index.memory_usage()),
o.memory_usage(index=True)
)
# sys.getsizeof will call the .memory_usage with
# deep=True, and add on some GC overhead
diff = res_deep - sys.getsizeof(o)
self.assertTrue(abs(diff) < 100)
test_base.py 文件源码
python
阅读 36
收藏 0
点赞 0
评论 0
评论列表
文章目录