| 284 | } |
| 285 | |
| 286 | void printPerformanceReport(std::vector<InferenceTrace> const& trace, ReportingOptions const& reportingOpts, |
| 287 | InferenceOptions const& infOpts, std::ostream& osInfo, std::ostream& osWarning, std::ostream& osVerbose) |
| 288 | { |
| 289 | int32_t batchSize = infOpts.batch; |
| 290 | float const warmupMs = infOpts.warmup; |
| 291 | auto const isNotWarmup = [&warmupMs](const InferenceTrace& a) { return a.computeStart >= warmupMs; }; |
| 292 | auto const noWarmup = std::find_if(trace.begin(), trace.end(), isNotWarmup); |
| 293 | int32_t const warmups = noWarmup - trace.begin(); |
| 294 | float const benchTime = trace.back().d2hEnd - noWarmup->h2dStart; |
| 295 | // when implicit batch used, batchSize = options.inference.batch, which is parsed through --batch |
| 296 | // when explicit batch used, batchSize = options.inference.batch = 0 |
| 297 | // treat inference with explicit batch as a single query and report the throughput |
| 298 | batchSize = batchSize ? batchSize : 1; |
| 299 | printProlog(warmups * batchSize, (trace.size() - warmups) * batchSize, warmupMs, benchTime, osInfo); |
| 300 | |
| 301 | std::vector<InferenceTime> timings(trace.size() - warmups); |
| 302 | std::transform(noWarmup, trace.end(), timings.begin(), traceToTiming); |
| 303 | printTiming(timings, reportingOpts.avgs, osInfo); |
| 304 | printEpilog( |
| 305 | timings, benchTime, reportingOpts.percentiles, batchSize, infOpts.infStreams, osInfo, osWarning, osVerbose); |
| 306 | |
| 307 | if (!reportingOpts.exportTimes.empty()) |
| 308 | { |
| 309 | exportJSONTrace(trace, reportingOpts.exportTimes, warmups); |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | //! Printed format: |
| 314 | //! [ value, ...] |
no test coverage detected