diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 35880df..c1f227d 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,7 +1,11 @@ -## v0.4.0 (2011/06/16) ## +## v0.4.0 (HEAD) ## Compatible with node v0.4.x +Features: + +* rps is now a separate stat from result codes + ## v0.3.0 (2011/06/16) ## Compatible with node v0.3.x diff --git a/lib/stats.js b/lib/stats.js index f2a9dbf..b49ab1e 100644 --- a/lib/stats.js +++ b/lib/stats.js @@ -198,7 +198,6 @@ ResultsCounter.prototype = { items[i] = this.items[i]; } items.total = this.length; - items.rps = Number((this.length / ((new Date() - this.start) / 1000)).toFixed(1)); return items; }, merge: function(other) { @@ -293,7 +292,7 @@ Rate.prototype = { this.length++; }, get: function() { - return this.length / ((new Date() - this.start) / 1000); + return Number((this.length / ((new Date() - this.start) / 1000)).toFixed(1)); }, clear: function() { this.start = new Date(); diff --git a/nodeload.js b/nodeload.js index e692065..6cc0180 100755 --- a/nodeload.js +++ b/nodeload.js @@ -20,12 +20,12 @@ this.length+=other.length;this.sum+=other.sum;this.min=(other.min!==-1&&(other.m this.extra=this.extra.concat(other.extra);this.sorted=false;}};var Accumulator=stats.Accumulator=function Accumulator(){this.type='Accumulator';this.total=0;this.length=0;};Accumulator.prototype={put:function(stat){this.total+=stat;this.length++;},get:function(){return this.total;},clear:function(){this.total=0;this.length=0;},summary:function(){return{total:this.total};},merge:function(other){this.total+=other.total;this.length+=other.length;}};var ResultsCounter=stats.ResultsCounter=function ResultsCounter(){this.type='ResultsCounter';this.start=new Date();this.items={};this.length=0;};ResultsCounter.prototype={put:function(item){if(this.items[item]!==undefined){this.items[item]++;}else{this.items[item]=1;} this.length++;},get:function(item){if(item.length>0){var total=0;for(var i in item){total+=this.items[i];} return total;}else{return this.items[item];}},clear:function(){this.start=new Date();this.items={};this.length=0;},summary:function(){var items={};for(var i in this.items){items[i]=this.items[i];} -items.total=this.length;items.rps=Number((this.length/((new Date()-this.start)/1000)).toFixed(1));return items;},merge:function(other){for(var i in other.items){if(this.items[i]!==undefined){this.items[i]+=other.items[i];}else{this.items[i]=other.items[i];}} +items.total=this.length;return items;},merge:function(other){for(var i in other.items){if(this.items[i]!==undefined){this.items[i]+=other.items[i];}else{this.items[i]=other.items[i];}} this.length+=other.length;}};var Uniques=stats.Uniques=function Uniques(){this.type='Uniques';this.start=new Date();this.items={};this.uniques=0;this.length=0;};Uniques.prototype={put:function(item){if(this.items[item]!==undefined){this.items[item]++;}else{this.items[item]=1;this.uniques++;} this.length++;},get:function(){return this.uniques;},clear:function(){this.items={};this.uniques=0;this.length=0;},summary:function(){return{total:this.length,uniqs:this.uniques};},merge:function(other){for(var i in other.items){if(this.items[i]!==undefined){this.items[i]+=other.items[i];}else{this.items[i]=other.items[i];this.uniques++;}} this.length+=other.length;}};var Peak=stats.Peak=function Peak(){this.type='Peak';this.peak=0;this.length=0;};Peak.prototype={put:function(item){if(this.peak0){this.interval.clear();} this.lastSummary=null;},summary:function(){if(this.lastSummary){return this.lastSummary;} return{interval:this.interval.summary(),cumulative:this.cumulative.summary()};},merge:function(other){this.interval.merge(other);this.cumulative.merge(other);}};var StatsGroup=stats.StatsGroup=function StatsGroup(){Object.defineProperty(this,'name',{enumerable:false,writable:true,});Object.defineProperty(this,'put',{enumerable:false,value:function(statNameOrVal,val){if(arguments.length<2){for(var i in this){this[i].put(statNameOrVal);}}else{if(this[statNameOrVal]){this[statNameOrVal].put(val);}}}});Object.defineProperty(this,'get',{enumerable:false,value:function(statName){if(arguments.length===1){var val={};for(var i in this){val[i]=this[i].get.apply(this[i],arguments);}