Skip to content

Commit

Permalink
tests/: added test_4090().
Browse files Browse the repository at this point in the history
  • Loading branch information
julian-smith-artifex-com committed Nov 28, 2024
1 parent db6ba8d commit 0febb6e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Binary file added tests/resources/test_4090.pdf
Binary file not shown.
27 changes: 27 additions & 0 deletions tests/test_2791.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,30 @@ def get_stat():
assert ratio >= 0.990 and ratio < 1.027, f'{ratio=}'
else:
pass


def test_4090():
print(f'test_4090(): {os.environ.get("PYTHONMALLOC")=}.')
import psutil
process = psutil.Process()
rsss = list()
def rss():
ret = process.memory_info().rss
rsss.append(ret)
return ret

path = os.path.normpath(f'{__file__}/../../tests/resources/test_4090.pdf')
for i in range(100):
d = dict()
d[i] = dict()
with pymupdf.open(path) as document:
for j, page in enumerate(document):
d[i][j] = page.get_text('rawdict')
print(f'test_4090(): {i}: {rss()=}')
print(f'test_4090(): {rss()=}')
gc.collect()
print(f'test_4090(): {rss()=}')
r1 = rsss[2]
r2 = rsss[-1]
r = r2 / r1
assert 0.95 <= r < 1.05, f'{r1=} {r2=} {r=}.'

0 comments on commit 0febb6e

Please sign in to comment.