Commit b4a1f792 authored by Enrico Bacis's avatar Enrico Bacis Committed by Commit Bot

[tool] prevent crash in tools/perf-to-html.py

The perf tests results are used by tools/perf-to-html.py to generate
html pages. Since the results are used as divisors to compute
percentages, when the one of them happens to be zero, the script
crashes.  This CL prevent the crash and uses the text "NaN" instead of
the percentage.

R=machenbach@chromium.org
CC=​ahaas@chromium.org,clemensh@chromium.org

Bug: chromium:761816
Change-Id: I482a85150c8323a7a837e6d589feee88279831cd
Reviewed-on: https://chromium-review.googlesource.com/649626
Commit-Queue: Enrico Bacis <enricobacis@google.com>
Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47806}
parent 6441d234
......@@ -70,20 +70,24 @@ class Result:
self.notable_ = 0
self.percentage_string_ = ""
# compute notability and significance.
if hasScoreUnits:
compare_num = 100*self.result_/self.master_result_ - 100
else:
compare_num = 100*self.master_result_/self.result_ - 100
if abs(compare_num) > 0.1:
self.percentage_string_ = "%3.1f" % (compare_num)
z = ComputeZ(self.master_result_, self.master_sigma_, self.result_, count)
p = ComputeProbability(z)
if p < PROBABILITY_CONSIDERED_SIGNIFICANT:
self.significant_ = True
if compare_num >= PERCENT_CONSIDERED_SIGNIFICANT:
self.notable_ = 1
elif compare_num <= -PERCENT_CONSIDERED_SIGNIFICANT:
self.notable_ = -1
try:
if hasScoreUnits:
compare_num = 100*self.result_/self.master_result_ - 100
else:
compare_num = 100*self.master_result_/self.result_ - 100
if abs(compare_num) > 0.1:
self.percentage_string_ = "%3.1f" % (compare_num)
z = ComputeZ(self.master_result_, self.master_sigma_, self.result_, count)
p = ComputeProbability(z)
if p < PROBABILITY_CONSIDERED_SIGNIFICANT:
self.significant_ = True
if compare_num >= PERCENT_CONSIDERED_SIGNIFICANT:
self.notable_ = 1
elif compare_num <= -PERCENT_CONSIDERED_SIGNIFICANT:
self.notable_ = -1
except ZeroDivisionError:
self.percentage_string_ = "NaN"
self.significant_ = True
def result(self):
return self.result_
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment