| 130 | } |
| 131 | |
| 132 | BenchmarkStats MeasureBenchmark( |
| 133 | const std::function<bool()> &operation, |
| 134 | bool &ok, |
| 135 | int warmup_runs = 1, |
| 136 | int measured_runs = 5) { |
| 137 | ok = true; |
| 138 | for (int index = 0; index < warmup_runs; ++index) { |
| 139 | if (!operation()) { |
| 140 | ok = false; |
| 141 | return {}; |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | std::vector<long long> samples; |
| 146 | samples.reserve(static_cast<size_t>(measured_runs)); |
| 147 | for (int index = 0; index < measured_runs; ++index) { |
| 148 | bool run_ok = false; |
| 149 | const long long elapsed_ms = MeasureMilliseconds(operation, run_ok); |
| 150 | if (!run_ok) { |
| 151 | ok = false; |
| 152 | samples.clear(); |
| 153 | return {}; |
| 154 | } |
| 155 | samples.push_back(elapsed_ms); |
| 156 | } |
| 157 | return BuildBenchmarkStats(std::move(samples)); |
| 158 | } |
| 159 | |
| 160 | struct RealImageCase { |
| 161 | std::wstring label; |
no test coverage detected