Run the test N times. Args: image: The test image to compress. block_size: The block size to use. preset: The quality-performance preset to use. repeats: The number of test runs. keep_output: Should the test preserve outpu
(self, image: TestImage, block_size: str, preset: str,
repeats: int, keep_output: bool = True,
threads: Optional[int] = None)
| 218 | return re.compile('^(?!x)x$') |
| 219 | |
| 220 | def run_test(self, image: TestImage, block_size: str, preset: str, |
| 221 | repeats: int, keep_output: bool = True, |
| 222 | threads: Optional[int] = None) -> RunResult: |
| 223 | ''' |
| 224 | Run the test N times. |
| 225 | |
| 226 | Args: |
| 227 | image: The test image to compress. |
| 228 | block_size: The block size to use. |
| 229 | preset: The quality-performance preset to use. |
| 230 | repeats: The number of test runs. |
| 231 | keep_output: Should the test preserve output images? |
| 232 | threads: The thread count to use. |
| 233 | |
| 234 | Return: |
| 235 | Tuple containing PSNR in dB, total time in seconds, coding time |
| 236 | in seconds, and coding rate in MT/s. |
| 237 | ''' |
| 238 | # pylint: disable=assignment-from-no-return |
| 239 | command = self.build_cli(image, block_size, preset, keep_output, |
| 240 | threads) |
| 241 | |
| 242 | # Execute test runs keeping best results |
| 243 | best_psnr = 0.0 |
| 244 | best_total_time = sys.float_info.max |
| 245 | best_coding_time = sys.float_info.max |
| 246 | best_coding_rate = 0.0 |
| 247 | |
| 248 | for _ in range(0, repeats): |
| 249 | output = self.execute(command) |
| 250 | result = self.parse_output(image, output) |
| 251 | |
| 252 | # Keep the best results (highest PSNR, lowest times, highest rate) |
| 253 | best_psnr = max(best_psnr, result[0]) |
| 254 | best_total_time = min(best_total_time, result[1]) |
| 255 | best_coding_time = min(best_coding_time, result[2]) |
| 256 | best_coding_rate = max(best_coding_rate, result[3]) |
| 257 | |
| 258 | return (best_psnr, best_total_time, best_coding_time, best_coding_rate) |
| 259 | |
| 260 | |
| 261 | class Encoder2x(EncoderBase): |