| 578 | } |
| 579 | |
| 580 | static void run_implementation(const uint8_t *input, uint8_t *output, |
| 581 | struct hash_impl *impl, unsigned size) |
| 582 | { |
| 583 | uint64_t t0, t1; |
| 584 | unsigned nruns = specified_runs ? specified_runs : (1 << 30) / size; |
| 585 | unsigned outlen = 0, outcrc = 0; |
| 586 | unsigned i, j, val; |
| 587 | double mtime, ttime = 0, ttime2 = 0, stime; |
| 588 | uint8_t outref[MAX_OUTPUT_SIZE]; |
| 589 | |
| 590 | if (enabled_libs && !av_stristr(enabled_libs, impl->lib) || |
| 591 | enabled_algos && !av_stristr(enabled_algos, impl->name)) |
| 592 | return; |
| 593 | if (!sscanf(impl->output, "crc:%x", &outcrc)) { |
| 594 | outlen = strlen(impl->output) / 2; |
| 595 | for (i = 0; i < outlen; i++) { |
| 596 | sscanf(impl->output + i * 2, "%02x", &val); |
| 597 | outref[i] = val; |
| 598 | } |
| 599 | } |
| 600 | for (i = 0; i < 8; i++) /* heat caches */ |
| 601 | impl->run(output, input, size); |
| 602 | for (i = 0; i < nruns; i++) { |
| 603 | memset(output, 0, size); /* avoid leftovers from previous runs */ |
| 604 | t0 = AV_READ_TIME(); |
| 605 | impl->run(output, input, size); |
| 606 | t1 = AV_READ_TIME(); |
| 607 | if (outlen ? memcmp(output, outref, outlen) : |
| 608 | crc32(output, size) != outcrc) { |
| 609 | fprintf(stderr, "Expected: "); |
| 610 | if (outlen) |
| 611 | for (j = 0; j < outlen; j++) |
| 612 | fprintf(stderr, "%02x", output[j]); |
| 613 | else |
| 614 | fprintf(stderr, "%08x", crc32(output, size)); |
| 615 | fprintf(stderr, "\n"); |
| 616 | fatal_error("output mismatch"); |
| 617 | } |
| 618 | mtime = (double)(t1 - t0) / size; |
| 619 | ttime += mtime; |
| 620 | ttime2 += mtime * mtime; |
| 621 | } |
| 622 | |
| 623 | ttime /= nruns; |
| 624 | ttime2 /= nruns; |
| 625 | stime = sqrt(ttime2 - ttime * ttime); |
| 626 | printf("%-10s %-12s size: %7d runs: %6d time: %8.3f +- %.3f\n", |
| 627 | impl->lib, impl->name, size, nruns, ttime, stime); |
| 628 | fflush(stdout); |
| 629 | } |
| 630 | |
| 631 | #define IMPL_USE(lib, name, symbol, output) \ |
| 632 | { #lib, name, run_ ## lib ## _ ## symbol, output }, |
no test coverage detected