(unused_argv)
| 110 | |
| 111 | |
| 112 | def main(unused_argv): |
| 113 | logging.set_verbosity(logging.INFO) |
| 114 | np.random.seed(0) |
| 115 | |
| 116 | thread_counts = [1, 2, 4, 6, 8, 10, 12, 14, 16, 32] |
| 117 | |
| 118 | logger.info("Warming up...") |
| 119 | warmup_image = _image_of_size(256) |
| 120 | for thread_count in thread_counts: |
| 121 | bench(warmup_image, thread_count) |
| 122 | |
| 123 | logger.info("Running...") |
| 124 | results = {} |
| 125 | image = _image_of_size(4096) |
| 126 | headers = ("THREADS", "TOTAL_TIME", "UNIT_TIME", "SPEEDUP", "PARALLELISM") |
| 127 | logger.info(_format_line(headers, headers)) |
| 128 | for thread_count in thread_counts: |
| 129 | time.sleep(1.0) |
| 130 | total_time = min( |
| 131 | bench(image, thread_count) for _ in range(3) |
| 132 | ) # best-of-three timing |
| 133 | unit_time = total_time / thread_count |
| 134 | if total_time < 2.0: |
| 135 | logger.warning( |
| 136 | "This benchmark is running too quickly! This " |
| 137 | "may cause misleading timing data. Consider " |
| 138 | "increasing the image size until it takes at " |
| 139 | "least 2.0s to encode one image." |
| 140 | ) |
| 141 | results[thread_count] = unit_time |
| 142 | speedup = results[1] / results[thread_count] |
| 143 | parallelism = speedup / thread_count |
| 144 | fields = (thread_count, total_time, unit_time, speedup, parallelism) |
| 145 | logger.info(_format_line(headers, fields)) |
| 146 | |
| 147 | |
| 148 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected
searching dependent graphs…