chukwa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ey...@apache.org
Subject svn commit: r781233 - in /hadoop/chukwa/trunk: CHANGES.txt src/web/hicc/js/flot.extend.js
Date Wed, 03 Jun 2009 01:00:22 GMT
Author: eyang
Date: Wed Jun  3 01:00:22 2009
New Revision: 781233

URL: http://svn.apache.org/viewvc?rev=781233&view=rev
Log:
CHUKWA-275. Add standard deviation to statics calculation for HICC charts. (Eric Yang)


Modified:
    hadoop/chukwa/trunk/CHANGES.txt
    hadoop/chukwa/trunk/src/web/hicc/js/flot.extend.js

Modified: hadoop/chukwa/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/CHANGES.txt?rev=781233&r1=781232&r2=781233&view=diff
==============================================================================
--- hadoop/chukwa/trunk/CHANGES.txt (original)
+++ hadoop/chukwa/trunk/CHANGES.txt Wed Jun  3 01:00:22 2009
@@ -14,6 +14,8 @@
 
   IMPROVEMENTS
 
+    CHUKWA-275. Add standard deviation to statics calculation for HICC charts. (Eric Yang)
+
     CHUKWA-137. Add collector IP to the dataSink fileName. (Jerome Boulon via asrabkin)
 
     CHUKWA-258. More detailed logging of SQL errors. (asrabkin)

Modified: hadoop/chukwa/trunk/src/web/hicc/js/flot.extend.js
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/js/flot.extend.js?rev=781233&r1=781232&r2=781233&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/js/flot.extend.js (original)
+++ hadoop/chukwa/trunk/src/web/hicc/js/flot.extend.js Wed Jun  3 01:00:22 2009
@@ -5,56 +5,43 @@
  * calculcate the min, max, average of the data set
  */
 function getStatis(data) {
-  first=true;
-  min=0;
-  max=0;
-  average=0;
-  sum=0;
-  count=0;
-  last=0;
+  var first=true;
+  var min=0;
+  var max=0;
+  var average=0;
+  var sum=0;
+  var count=0;
+  var last=0;
+  var sum_sqr=0.0;
   for (i=0; i<data.length;i++) {
     x=data[i][0];
     y=data[i][1];
     if (bound!=null) {
-      if ((x >= bound.xmin) && (x <=bound.xmax) &&
-	  (y >= bound.ymin) && (y <=bound.ymax)) {
-	if  (first) {
-	  min=y;
-	  max=y;
-	  first=false;
-	} else {
-	  if (y < min) {
-	    min=y;
-	  }
-	  if (y > max) {
-	    max=y;
-	  }
-	}
-	sum+=y;
-	count+=1;
-	average=sum/count;
-	last=y;
+      if (!((x >= bound.xmin) && (x <=bound.xmax) &&
+	  (y >= bound.ymin) && (y <=bound.ymax))) {
+        continue;
       }
+    }
+    if  (first) {
+      min=y;
+      max=y;
+      first=false;
     } else {
-      if  (first) {
-	min=y;
-	max=y;
-	first=false;
-      } else {
-	if (y < min) {
-	  min=y;
-	}
-	if (y > max) {
-	  max=y;
-	}
+      if (y < min) {
+        min=y;
+      }
+      if (y > max) {
+        max=y;
       }
-      sum+=y;
-      count+=1;
-      average=sum/count;
-      last=y;
     }
+    sum+=y;
+    count+=1;
+    last=y;
+    sum_sqr=sum_sqr+Math.pow(y,2);
   }
-  return {min: min, max: max, average: average, sum: sum, count: count, last: last};
+  average=sum/count;
+  stdev=Math.sqrt(sum_sqr/count-Math.pow(average,2));
+  return {min: min, max: max, average: average, stdev: stdev, sum: sum, count: count, last:
last};
 }
 
 /*
@@ -73,7 +60,7 @@
   dataTable+='<br/>';
   dataTable+='<table class="statisTable small_font">';
   dataTable+='<thead>';
-  dataTable+='<tr><th>Series</th><th>Maximum</th><th>Average</th><th>Minimum</th><th>Last</th></tr>';
 
+  dataTable+='<tr><th>Series</th><th>Maximum</th><th>Average</th><th>Minimum</th><th>St.
Deviation</th><th>Last</th></tr>';  
   dataTable+='</thead>';
   for (j = 0; j < _series.length; ++j) {
     statis = getStatis(_series[j].data);
@@ -82,6 +69,7 @@
     dataTable+='<td align="right">'+toFixed(statis.max,2)+'</td>';
     dataTable+='<td align="right">'+toFixed(statis.average,2)+'</td>';
     dataTable+='<td align="right">'+toFixed(statis.min,2)+'</td>';
+    dataTable+='<td align="right">'+toFixed(statis.stdev,2)+'</td>';
     dataTable+='<td align="right">'+toFixed(statis.last,2)+'</td>';
     dataTable+='</tr>';
   }



Mime
View raw message