|
1 | | -Benchmarks |
2 | | -========== |
| 1 | +Decoding Benchmarks |
| 2 | +=================== |
3 | 3 |
|
4 | 4 | Tests performed on Intel CPU i7-9700. |
5 | 5 |
|
@@ -91,3 +91,50 @@ Moving to ``ctx_mem`` = ``True`` what is by default now, gives much more signifi |
91 | 91 | Reading HEIF metadata and image properties gives us ``3x`` faster speed. |
92 | 92 | Decoding of small images, what we test here by decoding thumbnails, gives us ``30%`` increase of speed. |
93 | 93 | Decoding of big images becomes faster by 5%, after we switch to ``ctx_mem`` = ``True``. |
| 94 | + |
| 95 | +Encoding benchmarks |
| 96 | +=================== |
| 97 | + |
| 98 | +Comparing 0.2.5 and 0.3.0 on CPython 3.10 |
| 99 | + |
| 100 | +.. code-block:: python |
| 101 | +
|
| 102 | + DATASET = [Path("rgb8_512_512_1_2.heic"), Path("etc_heif/nokia/alpha_3_2.heic"), Path("rgb10_639_480_1_3.heic")] |
| 103 | +
|
| 104 | +Benchmark code A |
| 105 | +---------------- |
| 106 | + |
| 107 | +.. code-block:: python |
| 108 | +
|
| 109 | + def save_heif_file(): |
| 110 | + out_buf = BytesIO() |
| 111 | + for image_path in DATASET: |
| 112 | + heif_file = open_heif(image_path) |
| 113 | + heif_file.save(out_buf) |
| 114 | +
|
| 115 | + benchmark.pedantic(save_heif_file, iterations=1, rounds=40, warmup_rounds=1) |
| 116 | +
|
| 117 | +Benchmark code B |
| 118 | +---------------- |
| 119 | + |
| 120 | +.. code-block:: python |
| 121 | +
|
| 122 | + def pillow_save_heif(): |
| 123 | + out_buf = BytesIO() |
| 124 | + for image_path in DATASET: |
| 125 | + image = Image.open(image_path) |
| 126 | + image.save(out_buf, save_all=True, format="HEIF") |
| 127 | +
|
| 128 | + benchmark.pedantic(pillow_save_heif, iterations=1, rounds=40, warmup_rounds=1) |
| 129 | +
|
| 130 | ++-------------------------------+----------+----------+ |
| 131 | +| Benchmark | 0.2.5 | 0.3.0 | |
| 132 | ++===============================+==========+==========+ |
| 133 | +| **A** `HeiFile` mem_ctx=False | 1.81 s | 1.79 s | |
| 134 | ++-------------------------------+----------+----------+ |
| 135 | +| **A** `HeiFile` mem_ctx=True | 1.80 s | 1.78 s | |
| 136 | ++-------------------------------+----------+----------+ |
| 137 | +| **B** `Pillow` mem_ctx=False | 1.92 s | 1.90 s | |
| 138 | ++-------------------------------+----------+----------+ |
| 139 | +| **B** `Pillow` mem_ctx=True | 1.91 s | 1.89 s | |
| 140 | ++-------------------------------+----------+----------+ |
0 commit comments