File: test_perfs.py

package info (click to toggle)
fpdf2 2.8.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 53,860 kB
  • sloc: python: 39,487; sh: 133; makefile: 12
file content (26 lines) | stat: -rw-r--r-- 800 bytes parent folder | download | duplicates (2)
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
from pathlib import Path

from test.conftest import ensure_exec_time_below, ensure_rss_memory_below

from fpdf import FPDF

HERE = Path(__file__).resolve().parent
PNG_FILE_PATHS = list((HERE / "image/png_images/").glob("*.png"))
PNG_FILE_PATHS.extend(
    file_path
    for file_path in (HERE / "image/png_test_suite/").glob("*.png")
    if not file_path.name.startswith("x")
)


@ensure_exec_time_below(seconds=12)
@ensure_rss_memory_below(mib=30)  # VERY dependent on the environment
def test_intense_image_rendering(tmp_path):
    pdf = FPDF()
    for _ in range(2000):
        pdf.add_page()
        for i, png_file_path in enumerate(PNG_FILE_PATHS):
            x = (i % 13) * 16
            y = (i // 13) * 16
            pdf.image(png_file_path, x=x, y=y)
    pdf.output(tmp_path / "out.pdf")