As suggested by berick, tweaking latency tester
to sequentially fire off pings.
Signed-off by: Cesar Velez <cesar.velez@equinoxinitiative.org>
$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(){
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();
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();
+ }
+ });
}
}