Fix JSBench which causes math domain error in run-benchmark script.
authordewei_zhu@apple.com <dewei_zhu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 14 May 2016 04:58:41 +0000 (04:58 +0000)
committerdewei_zhu@apple.com <dewei_zhu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 14 May 2016 04:58:41 +0000 (04:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=157697
<rdar://problem/26279292>

Reviewed by Ryosuke Niwa.

Some tests of JSBench give time usage to be 0 ms which will causes error while calculating geometric mean.
Also fix a round-off error while calculating stdev.

* Scripts/webkitpy/benchmark_runner/benchmark_results.py:
(BenchmarkResults._format_values):
* Scripts/webkitpy/benchmark_runner/data/patches/JSBench.patch:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@200914 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/benchmark_runner/benchmark_results.py
Tools/Scripts/webkitpy/benchmark_runner/data/patches/JSBench.patch

index 582ed6c..408beab 100644 (file)
@@ -1,3 +1,18 @@
+2016-05-13  Dewei Zhu  <dewei_zhu@apple.com>
+
+        Fix JSBench which causes math domain error in run-benchmark script.
+        https://bugs.webkit.org/show_bug.cgi?id=157697
+        <rdar://problem/26279292>
+
+        Reviewed by Ryosuke Niwa.
+
+        Some tests of JSBench give time usage to be 0 ms which will causes error while calculating geometric mean.
+        Also fix a round-off error while calculating stdev.
+
+        * Scripts/webkitpy/benchmark_runner/benchmark_results.py:
+        (BenchmarkResults._format_values):
+        * Scripts/webkitpy/benchmark_runner/data/patches/JSBench.patch:
+
 2016-05-13  Brady Eidson  <beidson@apple.com>
 
         Extend protector naming code style guideline to cover operator= assignment.
index 018e5b4..3fc4fa6 100644 (file)
@@ -89,7 +89,8 @@ class BenchmarkResults(object):
         if sample_count <= 1:
             sample_stdev = 0
         else:
-            sample_stdev = math.sqrt(square_sum / (sample_count - 1) - total * total / (sample_count - 1) / sample_count)
+            # Be careful about round-off error when sample_stdev is 0.
+            sample_stdev = math.sqrt(max(0, square_sum / (sample_count - 1) - total * total / (sample_count - 1) / sample_count))
 
         unit = cls._unit_from_metric(metric_name)
 
index ff3faf0..26a6f43 100644 (file)
@@ -24,7 +24,7 @@ index 4b9d269..876fddd 100644
                  if (bmresults.length == 0) continue;
  
 +                if (pr)
-+                    tests[benchmark] = {'metrics': {'Time': {'current': bmresults}}};
++                    tests[benchmark] = {'metrics': {'Time': {'current': bmresults.map(function (value) { return value || 1; })}}};
 +
                  // get the raw results
                  var rr = spc2 + mode + ": [";