| 171 | } |
| 172 | |
| 173 | PerformanceResult getPerformanceResult(std::vector<InferenceTime> const& timings, |
| 174 | std::function<float(InferenceTime const&)> metricGetter, std::vector<float> const& percentiles) |
| 175 | { |
| 176 | auto const metricComparator |
| 177 | = [metricGetter](InferenceTime const& a, InferenceTime const& b) { return metricGetter(a) < metricGetter(b); }; |
| 178 | auto const metricAccumulator = [metricGetter](float acc, InferenceTime const& a) { return acc + metricGetter(a); }; |
| 179 | std::vector<InferenceTime> newTimings = timings; |
| 180 | std::sort(newTimings.begin(), newTimings.end(), metricComparator); |
| 181 | PerformanceResult result; |
| 182 | result.min = metricGetter(newTimings.front()); |
| 183 | result.max = metricGetter(newTimings.back()); |
| 184 | result.mean = std::accumulate(newTimings.begin(), newTimings.end(), 0.0F, metricAccumulator) / newTimings.size(); |
| 185 | result.median = findMedian(newTimings, metricGetter); |
| 186 | for (auto percentile : percentiles) |
| 187 | { |
| 188 | result.percentiles.emplace_back(findPercentile(percentile, newTimings, metricGetter)); |
| 189 | } |
| 190 | result.coeffVar = findCoeffOfVariance(newTimings, metricGetter, result.mean); |
| 191 | return result; |
| 192 | } |
| 193 | |
| 194 | void printEpilog(std::vector<InferenceTime> const& timings, float walltimeMs, std::vector<float> const& percentiles, |
| 195 | int32_t batchSize, int32_t infStreams, std::ostream& osInfo, std::ostream& osWarning, std::ostream& osVerbose) |
no test coverage detected