|
31 | 31 | from Crypto.Cipher import AES as PyCryptoDomeAES |
32 | 32 | import cv2 |
33 | 33 |
|
34 | | -from utils import add_common_args, load_dataset, name_matches, now_ns, tokenize_dataset |
| 34 | +from utils import add_common_args, load_dataset, should_run, now_ns, tokenize_dataset |
35 | 35 |
|
36 | 36 |
|
37 | 37 | def log_system_info(): |
@@ -258,55 +258,55 @@ def main() -> int: |
258 | 258 | tokens_mv = [memoryview(bytearray(token)) for token in tokens_b] |
259 | 259 |
|
260 | 260 | # Python bytes.translate (always allocating) |
261 | | - if name_matches("bytes.translate(new)", pattern): |
| 261 | + if should_run("bytes.translate(new)", pattern): |
262 | 262 | bench_translate("bytes.translate(new)", tokens_b, reverse, bytes_translate, args.time_limit) |
263 | 263 |
|
264 | 264 | # OpenCV allocating |
265 | | - if name_matches("opencv.LUT(new)", pattern): |
| 265 | + if should_run("opencv.LUT(new)", pattern): |
266 | 266 | bench_translate("opencv.LUT(new)", tokens_np, reverse_np, opencv_lut_allocating, args.time_limit) |
267 | 267 |
|
268 | 268 | # OpenCV in-place |
269 | | - if name_matches("opencv.LUT(inplace)", pattern): |
| 269 | + if should_run("opencv.LUT(inplace)", pattern): |
270 | 270 | bench_translate("opencv.LUT(inplace)", tokens_np, reverse_np, opencv_lut_inplace, args.time_limit) |
271 | 271 |
|
272 | 272 | # NumPy indexing allocating |
273 | | - if name_matches("numpy.indexing(new)", pattern): |
| 273 | + if should_run("numpy.indexing(new)", pattern): |
274 | 274 | bench_translate("numpy.indexing(new)", tokens_np, reverse_np, numpy_lut_indexing_allocating, args.time_limit) |
275 | 275 |
|
276 | 276 | # NumPy indexing in-place |
277 | | - if name_matches("numpy.indexing(inplace)", pattern): |
| 277 | + if should_run("numpy.indexing(inplace)", pattern): |
278 | 278 | bench_translate("numpy.indexing(inplace)", tokens_np, reverse_np, numpy_lut_indexing_inplace, args.time_limit) |
279 | 279 |
|
280 | 280 | # NumPy take allocating |
281 | | - if name_matches("numpy.take(new)", pattern): |
| 281 | + if should_run("numpy.take(new)", pattern): |
282 | 282 | bench_translate("numpy.take(new)", tokens_np, reverse_np, numpy_lut_take_allocating, args.time_limit) |
283 | 283 |
|
284 | 284 | # NumPy take in-place |
285 | | - if name_matches("numpy.take(inplace)", pattern): |
| 285 | + if should_run("numpy.take(inplace)", pattern): |
286 | 286 | bench_translate("numpy.take(inplace)", tokens_np, reverse_np, numpy_lut_take_inplace, args.time_limit) |
287 | 287 |
|
288 | 288 | # StringZilla allocating |
289 | | - if name_matches("stringzilla.translate(new)", pattern): |
| 289 | + if should_run("stringzilla.translate(new)", pattern): |
290 | 290 | bench_translate("stringzilla.translate(new)", tokens_b, reverse, sz_translate_allocating, args.time_limit) |
291 | 291 |
|
292 | 292 | # StringZilla in-place (need memoryviews for each token) |
293 | | - if name_matches("stringzilla.translate(inplace)", pattern): |
| 293 | + if should_run("stringzilla.translate(inplace)", pattern): |
294 | 294 | bench_translate("stringzilla.translate(inplace)", tokens_mv, reverse, sz_translate_inplace, args.time_limit) |
295 | 295 |
|
296 | 296 | # ---------------- Random byte generation ---------------- |
297 | 297 | print() |
298 | 298 | print("--- Random Byte Generation ---") |
299 | 299 | sizes = sizes_from_tokens(tokens_b) |
300 | 300 |
|
301 | | - if name_matches("pycryptodome.AES-CTR", pattern): |
| 301 | + if should_run("pycryptodome.AES-CTR", pattern): |
302 | 302 | bench_generator("pycryptodome.AES-CTR", sizes, make_pycryptodome_aes_ctr(), args.time_limit) |
303 | | - if name_matches("stringzilla.fill_random", pattern): |
| 303 | + if should_run("stringzilla.fill_random", pattern): |
304 | 304 | bench_generator("stringzilla.fill_random", sizes, make_stringzilla_fill_random(), args.time_limit) |
305 | | - if name_matches("stringzilla.random", pattern): |
| 305 | + if should_run("stringzilla.random", pattern): |
306 | 306 | bench_generator("stringzilla.random", sizes, sz.random, args.time_limit) |
307 | | - if name_matches("numpy.PCG64", pattern): |
| 307 | + if should_run("numpy.PCG64", pattern): |
308 | 308 | bench_generator("numpy.PCG64", sizes, make_numpy_pcg64(), args.time_limit) |
309 | | - if name_matches("numpy.Philox", pattern): |
| 309 | + if should_run("numpy.Philox", pattern): |
310 | 310 | bench_generator("numpy.Philox", sizes, make_numpy_philox(), args.time_limit) |
311 | 311 |
|
312 | 312 | return 0 |
|
0 commit comments