Output 0 instead of NaN in perftest-output.json

Subsequent recipe step requires the json to be valid.

TBR: terelius@webrtc.org
No-Try: True
Bug: webrtc:9767
Change-Id: I1b7457a147039772e2cb4dbdbc0eab3e699492be
Reviewed-on: https://webrtc-review.googlesource.com/101260
Reviewed-by: Oleh Prypin <oprypin@webrtc.org>
Commit-Queue: Oleh Prypin <oprypin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24782}
This commit is contained in:
Yves Gerey
2018-09-21 12:28:56 +02:00
committed by Commit Bot
parent 3ee3c40f95
commit c411cdfbc3

View File

@ -27,6 +27,10 @@ using std::vector;
namespace {
const int kQuickTestTimeoutMs = 500;
double SafeDiv(double a, double b) {
return b ? a / b : 0;
}
}
namespace webrtc {
@ -217,12 +221,13 @@ void BweTest::PrintResults(double max_throughput_kbps,
Stats<double> throughput_kbps,
std::map<int, Stats<double>> flow_delay_ms,
std::map<int, Stats<double>> flow_throughput_kbps) {
double utilization = throughput_kbps.GetMean() / max_throughput_kbps;
double utilization = SafeDiv(throughput_kbps.GetMean(), max_throughput_kbps);
webrtc::test::PrintResult("BwePerformance", GetTestName(), "Utilization",
utilization * 100.0, "%", false);
webrtc::test::PrintResult(
"BwePerformance", GetTestName(), "Utilization var coeff",
throughput_kbps.GetStdDev() / throughput_kbps.GetMean(), "", false);
SafeDiv(throughput_kbps.GetStdDev(), throughput_kbps.GetMean()), "",
false);
std::stringstream ss;
for (auto& kv : flow_throughput_kbps) {
ss.str("");
@ -246,8 +251,8 @@ void BweTest::PrintResults(double max_throughput_kbps,
squared_bitrate_sum += kv.second.GetMean() * kv.second.GetMean();
fairness_index += kv.second.GetMean();
}
fairness_index *= fairness_index;
fairness_index /= flow_throughput_kbps.size() * squared_bitrate_sum;
fairness_index *= SafeDiv(
fairness_index, flow_throughput_kbps.size() * squared_bitrate_sum);
}
webrtc::test::PrintResult("BwePerformance", GetTestName(), "Fairness",
fairness_index * 100, "%", false);