MCPcopy Create free account
hub / github.com/WallBreaker2/op / BuildBenchmarkStats

Function BuildBenchmarkStats

tests/opencv_test.cpp:109–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107};
108
109BenchmarkStats BuildBenchmarkStats(std::vector<long long> samples) {
110 BenchmarkStats stats;
111 if (samples.empty()) {
112 return stats;
113 }
114
115 std::sort(samples.begin(), samples.end());
116 stats.min_ms = samples.front();
117 stats.median_ms = samples[samples.size() / 2];
118 const size_t p95_index = std::min(samples.size() - 1, static_cast<size_t>((samples.size() * 95 + 99) / 100 - 1));
119 stats.p95_ms = samples[p95_index];
120 stats.avg_ms = static_cast<double>(std::accumulate(samples.begin(), samples.end(), 0LL)) /
121 static_cast<double>(samples.size());
122 return stats;
123}
124
125void RecordBenchmarkStats(const std::string &name, const BenchmarkStats &stats) {
126 ::testing::Test::RecordProperty(name + "_min_ms", stats.min_ms);

Callers 1

MeasureBenchmarkFunction · 0.85

Calls 4

emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected