diff options
author | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-17 19:19:38 +0000 |
---|---|---|
committer | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-17 19:19:38 +0000 |
commit | 932019c5d5142284f6badffd481c48703485e66e (patch) | |
tree | c2acb47f6ce69189c069a2ddd754b2877b063398 /chrome | |
parent | 8e57bd011bfca2b1b7c63b250d6abc0c4922fe92 (diff) | |
download | chromium_src-932019c5d5142284f6badffd481c48703485e66e.zip chromium_src-932019c5d5142284f6badffd481c48703485e66e.tar.gz chromium_src-932019c5d5142284f6badffd481c48703485e66e.tar.bz2 |
Remove min/max values from averages in benchmark.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/399039
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32198 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/common/extensions/docs/examples/extensions/benchmark/options.html | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/chrome/common/extensions/docs/examples/extensions/benchmark/options.html b/chrome/common/extensions/docs/examples/extensions/benchmark/options.html index 41d5e70..dcc1ff2 100644 --- a/chrome/common/extensions/docs/examples/extensions/benchmark/options.html +++ b/chrome/common/extensions/docs/examples/extensions/benchmark/options.html @@ -99,12 +99,24 @@ Array.min = function(array) { return Math.min.apply( Math, array ); }; -// Compute the average of an array +// Compute the average of an array, removing the min/max. Array.avg = function(array) { var count = array.length; var sum = 0; + var min = array[0]; + var max = array[0]; for (var i = 0; i < count; i++) { sum += array[i]; + if (array[i] < min) { + min = array[i]; + } + if (array[i] > max) { + max = array[i]; + } + } + if (count >= 3) { + sum = sum - min - max; + count -= 2; } return (sum / count).toFixed(1); } |