/usr/lib/python2.7/dist-packages/openpyxl/benchmarks/memory.py is in python-openpyxl 2.3.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | """
Very simple memory use analysis
"""
import os
import openpyxl
from memory_profiler import memory_usage
def test_memory_use():
"""Naive test that assumes memory use will never be more than 120 % of
that for first 50 rows"""
folder = os.path.split(__file__)[0]
src = os.path.join(folder, "files", "very_large.xlsx")
wb = openpyxl.load_workbook(src, use_iterators=True)
ws = wb.active
initial_use = None
for n, line in enumerate(ws.iter_rows()):
if n % 50 == 0:
use = memory_usage(proc=-1, interval=1)[0]
if initial_use is None:
initial_use = use
assert use/initial_use < 1.2
print(n, use)
if __name__ == '__main__':
test_memory_use()
|