qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eal...@apache.org
Subject qpid-dispatch git commit: DISPATCH-1077 Fix rate calculation on Console's chord diagram.
Date Mon, 23 Jul 2018 11:11:02 GMT
Repository: qpid-dispatch
Updated Branches:
  refs/heads/master 2d6bef53a -> 69af7476e


DISPATCH-1077 Fix rate calculation on Console's chord diagram.


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/69af7476
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/69af7476
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/69af7476

Branch: refs/heads/master
Commit: 69af7476e1631ccfd1a223daec943f9aaad18570
Parents: 2d6bef5
Author: Ernest Allen <eallen@redhat.com>
Authored: Mon Jul 23 07:10:48 2018 -0400
Committer: Ernest Allen <eallen@redhat.com>
Committed: Mon Jul 23 07:10:48 2018 -0400

----------------------------------------------------------------------
 console/stand-alone/plugin/js/chord/data.js | 32 +++++++++++-------------
 1 file changed, 15 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/69af7476/console/stand-alone/plugin/js/chord/data.js
----------------------------------------------------------------------
diff --git a/console/stand-alone/plugin/js/chord/data.js b/console/stand-alone/plugin/js/chord/data.js
index 45e68a7..491b42b 100644
--- a/console/stand-alone/plugin/js/chord/data.js
+++ b/console/stand-alone/plugin/js/chord/data.js
@@ -20,7 +20,7 @@ under the License.
 /* global angular Promise */
 import { MIN_CHORD_THRESHOLD } from './matrix.js';
 
-const SAMPLES = 3;  // number of snapshots to use for rate calculations
+const SAMPLES = 3; // number of snapshots to use for rate calculations
 
 class ChordData { // eslint-disable-line no-unused-vars
   constructor(QDRService, isRate, converter) {
@@ -91,7 +91,7 @@ class ChordData { // eslint-disable-line no-unused-vars
           reject(Error('unable to fetch entities'));
           return;
         }
-        // the raw data received from the rouers
+        // the raw data received from the routers
         let values = [];
         // for each router in the network
         for (let nodeId in results) {
@@ -169,23 +169,21 @@ let calcRate = function (values, last_values, snapshots) {
   snapshots.push(angular.copy(last_values));
 
   let oldest = snapshots[0];
+  let newest = snapshots[snapshots.length-1];
   let rateValues = [];
-  let elapsed = (now - oldest.timestamp) / 1000;
+  let elapsed = (newest.timestamp - oldest.timestamp) / 1000;
+  let getValueFor = function (snap, value) {
+    for (let i=0; i<snap.values.length; i++) {
+      if (snap.values[i].ingress === value.ingress &&
+        snap.values[i].egress === value.egress &&
+        snap.values[i].address === value.address)
+        return snap.values[i].messages;
+    }
+  };
   values.forEach( function (value) {
-
-    let rate = 0;
-    let total = 0;
-    snapshots.forEach ( function (snap) {
-      let last_index = snap.values.findIndex( function (lv) {
-        return lv.ingress === value.ingress &&
-              lv.egress === value.egress &&
-              lv.address === value.address; 
-      });
-      if (last_index >= 0) {
-        total += snap.values[last_index].messages;
-      }
-    });
-    rate = (value.messages - (total / snapshots.length)) / elapsed;
+    let first = getValueFor(oldest, value);
+    let last = getValueFor(newest, value);
+    let rate = (last - first) / elapsed;
 
     rateValues.push({ingress: value.ingress, 
       egress: value.egress, 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message