Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

New statistics implemented

  • Loading branch information...
commit 1eac2a9eaa5f467464b20cd977353186a17e0401 1 parent f268101
@penartur authored
Showing with 34 additions and 8 deletions.
  1. +34 −8 lib/benchmark.js
View
42 lib/benchmark.js
@@ -20,8 +20,18 @@ var getTimer = function (timerType) {
}
var statistics = {
+ temporalDisrepancy: function (list) {
+ var sliceLength = Math.min(list.length / 2, 24);
+ return Math.round(100 * this.trimmedMean(list.slice(list.length - sliceLength, list.length)) / this.trimmedMean(list.slice(0, sliceLength))) / 100;
+ },
+ sort: function (list) {
+ if (!list.sorted) {
+ list.sort(function (a, b) { return (a - b); });
+ list.sorted = true;
+ }
+ },
median: function (list) {
- list.sort(function (a, b) { return (a - b); });
+ this.sort(list);
if (list.length % 2 == 0) {
return Math.round(list[list.length / 2 - 1] + list[list.length / 2]) / 2
} else {
@@ -37,21 +47,37 @@ var statistics = {
}
return Math.round(total / num);
},
+ trimmedMean: function (list) {
+ if (list.length < 3) {
+ return this.median(list);
+ }
+ this.sort(list);
+ return this.mean(list.slice(list.length / 3 - 1, 2 * list.length / 3 - 1));
+ },
max: function (list) {
return Math.max.apply(null, list);
},
all: function (list) {
+ //console.log(list);
+ var temporalDisrepancy = this.temporalDisrepancy(list);
+ var mean = this.mean(list);
+ var max = this.max(list);
+ var num = list.length;
+ this.sort(list);
+ var median = this.median(list);
+ var trimmedMean = this.mean(list.slice(list.length / 3 - 1, 2 * list.length / 3 - 1));
var result = {
- median: this.median(list),
- mean: this.mean(list),
- max: this.max(list),
- num: list.length
+ trMean: trimmedMean
+ //, median: median,
+ , teDisrepancy: temporalDisrepancy
+ //, mean: mean
+ , max: max
+ , num: num
};
- //console.log(list);
//console.log(result);
return result;
}
-}
+};
var Benchmark = function (engines, pages, options) {
this.engines = engines;
@@ -106,7 +132,7 @@ BenchmarkContext.prototype.requestPage = function (url, expectedLength, callback
request(url, function (error, response, body) {
var elapsed = timer.elapsed();
if (error) {
- callback(error, elapsed);
+ callback(new Error("An error occured while trying to process " + url + ": " + error), elapsed);
} else {
if (body.length != expectedLength) {
callback(new Error("Expected " + expectedLength + " bytes, got " + body.length + " bytes"), elapsed);

0 comments on commit 1eac2a9

Please sign in to comment.
Something went wrong with that request. Please try again.