LP#1739504 - Fire off each ping sequentially
authorCesar Velez <cesar.velez@equinoxinitiative.org>
Thu, 4 Jan 2018 17:56:12 +0000 (12:56 -0500)
committerCesar Velez <cesar.velez@equinoxinitiative.org>
Thu, 4 Jan 2018 17:56:12 +0000 (12:56 -0500)
As suggested by berick, tweaking latency tester
to sequentially fire off pings.

Signed-off by: Cesar Velez <cesar.velez@equinoxinitiative.org>

Open-ILS/web/js/ui/default/staff/admin/workstation/app.js

index b42503b..b05fe26 100644 (file)
@@ -948,7 +948,7 @@ function($scope , egCore , ngToast) {
     $scope.avrg = 0; // avrg latency
     $scope.canCopyCommand = document.queryCommandSupported('copy');
     var numPings = 0;
-    // fetch first 10
+    // initially fetch first 10 (gets a decent average)
 
     function calcAverage(){
 
@@ -967,7 +967,7 @@ function($scope , egCore , ngToast) {
     function ping(){
         $scope.isTesting = true;
         var t = Date.now();
-        egCore.net.request(
+        return egCore.net.request(
             "open-ils.pcrud", "opensrf.system.echo", "ping"
         ).then(function(resp){
             var t2 = Date.now();
@@ -988,9 +988,14 @@ function($scope , egCore , ngToast) {
         if (numPings >= 10){
             ping(); // just ping once after the initial ten
         } else {
-            for (var i=0; i<10; i++){
-                ping();
-            }
+            ping()
+                .then($scope.testLatency)
+                .then(function(){
+                    if (numPings == 9){
+                        $scope.tests.shift(); // toss first result
+                        $scope.avrg = calcAverage();
+                    }
+                });
         }
     }