From 1a8d65abf6e14b7a903c378034105a52605d1deb Mon Sep 17 00:00:00 2001 From: "paroga@webkit.org" Date: Sun, 26 Dec 2010 22:00:33 +0000 Subject: [PATCH] 2010-12-26 Patrick Gansterer Reviewed by Eric Seidel. Improve output of HTML parser benchmark https://bugs.webkit.org/show_bug.cgi?id=51611 Calculate and show median, min and max values. * benchmarks/parser/html-parser.html: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74671 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- WebCore/ChangeLog | 11 +++++++++++ WebCore/benchmarks/parser/html-parser.html | 29 +++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 7c76dca..d702348 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,14 @@ +2010-12-26 Patrick Gansterer + + Reviewed by Eric Seidel. + + Improve output of HTML parser benchmark + https://bugs.webkit.org/show_bug.cgi?id=51611 + + Calculate and show median, min and max values. + + * benchmarks/parser/html-parser.html: + 2010-12-26 Abhishek Arya Reviewed by Simon Fraser. diff --git a/WebCore/benchmarks/parser/html-parser.html b/WebCore/benchmarks/parser/html-parser.html index 56a40c3..f3e99ec 100644 --- a/WebCore/benchmarks/parser/html-parser.html +++ b/WebCore/benchmarks/parser/html-parser.html @@ -38,6 +38,32 @@ function computeAverage(values) { return sum / values.length; } +function computeMax(values) { + var max = values.length ? values[0] : 0; + for (var i = 1; i < values.length; i++) { + if (max < values[i]) + max = values[i]; + } + return max; +} + +function computeMedian(values) { + values.sort(function(a, b) { return a - b; }); + var len = values.length; + if (len % 2) + return values[(len-1)/2]; + return (values[len/2-1] + values[len/2]) / 2; +} + +function computeMin(values) { + var min = values.length ? values[0] : 0; + for (var i = 1; i < values.length; i++) { + if (min > values[i]) + min = values[i]; + } + return min; +} + function computeStdev(values) { var average = computeAverage(values); var sumOfSquaredDeviations = 0; @@ -51,7 +77,10 @@ function computeStdev(values) { function logStatistics(times) { log(""); log("avg " + computeAverage(times)); + log("median " + computeMedian(times)); log("stdev " + computeStdev(times)); + log("min " + computeMin(times)); + log("max " + computeMax(times)); } function run() { -- 2.7.4