////////////////////////////////////////////////////////////////////////
// Latency
////////////////////////////////////////////////////////////////////////
189615
func measureLatency(bucket s3.Bucket) (avg time.Duration, err error) {
	// Average over several runs until we've taken at least this much time.
	const minDuration time.Duration = 4 * time.Second

	var total time.Duration
	var numRuns int

	for ; total < minDuration; numRuns++ {
		timeBefore := time.Now()
		if _, err = storeData(bucket, 1); err != nil {
			return
		}

		total += time.Since(timeBefore)
	}

	avg = time.Duration(float64(total) / float64(numRuns))
	return
}
1219746
function() {
		// temp local vars
		var lastFlickDuration,
			tempReleasePos;

		// s = this
		var s = {
			lastFlickOffset: {},
			lastFlickDist: {},
			lastFlickSpeed: {},
			slowDownRatio:  {},
			slowDownRatioReverse:  {},
			speedDecelerationRatio:  {},
			speedDecelerationRatioAbs:  {},
			distanceOffset:  {},
			backAnimDestination: {},
			backAnimStarted: {},
			calculateSwipeSpeed: function(axis) {
				

				if( _posPoints.length > 1) {
					lastFlickDuration = _getCurrentTime() - _gestureCheckSpeedTime + 50;
					tempReleasePos = _posPoints[_posPoints.length-2][axis];
				} else {
					lastFlickDuration = _getCurrentTime() - _gestureStartTime; // total gesture duration
					tempReleasePos = _startPoint[axis];
				}
				s.lastFlickOffset[axis] = _currPoint[axis] - tempReleasePos;
				s.lastFlickDist[axis] = Math.abs(s.lastFlickOffset[axis]);
				if(s.lastFlickDist[axis] > 20) {
					s.lastFlickSpeed[axis] = s.lastFlickOffset[axis] / lastFlickDuration;
				} else {
					s.lastFlickSpeed[axis] = 0;
				}
				if( Math.abs(s.lastFlickSpeed[axis]) < 0.1 ) {
					s.lastFlickSpeed[axis] = 0;
				}
				
				s.slowDownRatio[axis] = 0.95;
				s.slowDownRatioReverse[axis] = 1 - s.slowDownRatio[axis];
				s.speedDecelerationRatio[axis] = 1;
			},

			calculateOverBoundsAnimOffset: function(axis, speed) {
				if(!s.backAnimStarted[axis]) {

					if(_panOffset[axis] > _currPanBounds.min[axis]) {
						s.backAnimDestination[axis] = _currPanBounds.min[axis];
						
					} else if(_panOffset[axis] < _currPanBounds.max[axis]) {
						s.backAnimDestination[axis] = _currPanBounds.max[axis];
					}

					if(s.backAnimDestination[axis] !== undefined) {
						s.slowDownRatio[axis] = 0.7;
						s.slowDownRatioReverse[axis] = 1 - s.slowDownRatio[axis];
						if(s.speedDecelerationRatioAbs[axis] < 0.05) {

							s.lastFlickSpeed[axis] = 0;
							s.backAnimStarted[axis] = true;

							_animateProp('bounceZoomPan'+axis,_panOffset[axis], 
								s.backAnimDestination[axis], 
								speed || 300, 
								framework.easing.sine.out, 
								function(pos) {
									_panOffset[axis] = pos;
									_applyCurrentZoomPan();
								}
							);

						}
					}
				}
			},

			// Reduces the speed by slowDownRatio (per 10ms)
			calculateAnimOffset: function(axis) {
				if(!s.backAnimStarted[axis]) {
					s.speedDecelerationRatio[axis] = s.speedDecelerationRatio[axis] * (s.slowDownRatio[axis] + 
												s.slowDownRatioReverse[axis] - 
												s.slowDownRatioReverse[axis] * s.timeDiff / 10);

					s.speedDecelerationRatioAbs[axis] = Math.abs(s.lastFlickSpeed[axis] * s.speedDecelerationRatio[axis]);
					s.distanceOffset[axis] = s.lastFlickSpeed[axis] * s.speedDecelerationRatio[axis] * s.timeDiff;
					_panOffset[axis] += s.distanceOffset[axis];

				}
			},

			panAnimLoop: function() {
				if ( _animations.zoomPan ) {
					_animations.zoomPan.raf = _requestAF(s.panAnimLoop);

					s.now = _getCurrentTime();
					s.timeDiff = s.now - s.lastNow;
					s.lastNow = s.now;
					
					s.calculateAnimOffset('x');
					s.calculateAnimOffset('y');

					_applyCurrentZoomPan();
					
					s.calculateOverBoundsAnimOffset('x');
					s.calculateOverBoundsAnimOffset('y');


					if (s.speedDecelerationRatioAbs.x < 0.05 && s.speedDecelerationRatioAbs.y < 0.05) {

						// round pan position
						_panOffset.x = Math.round(_panOffset.x);
						_panOffset.y = Math.round(_panOffset.y);
						_applyCurrentZoomPan();
						
						_stopAnimation('zoomPan');
						return;
					}
				}

			}
		};
		return s;
	}
939129
func (v *Stats) Latency() uint64 {
	ops := v.Writes + v.Reads
	if ops == 0 {
		return 0
	}
	return (uint64)((v.IoMs * 1000) / ops)
}
1087103
function advance() {
	const start = now();
	config.depth = ( config.depth || 0 ) + 1;

	while ( config.queue.length && !config.blocking ) {
		const elapsedTime = now() - start;

		if ( !defined.setTimeout || config.updateRate <= 0 || elapsedTime < config.updateRate ) {
			if ( priorityCount > 0 ) {
				priorityCount--;
			}

			config.queue.shift()();
		} else {
			setTimeout( advance, 13 );
			break;
		}
	}

	config.depth--;

	if ( !config.blocking && !config.queue.length && config.depth === 0 ) {
		done();
	}
}
186479
public final Latency withPercentile999th(double value) {
    double newValue = value;
    return new Latency(this.median, this.percentile98th, this.percentile99th, newValue, this.mean, this.min, this.max);
  }
576853
final void updateDelayInMillisecondsFrom(HttpResponse httpPollResponse) {
        final Long parsedDelayInMilliseconds = delayInMillisecondsFrom(httpPollResponse);
        if (parsedDelayInMilliseconds != null) {
            delayInMilliseconds = parsedDelayInMilliseconds;
        }
    }
49596
function AsyncInvokeLater(fn, receiver, arg) {
    ASSERT(arguments.length === 3);
    this._lateQueue.push(fn, receiver, arg);
    this._queueTick();
}
316729
public function latency($latency)
    {
        if($latency <= 1){
            $latency = $latency * 1000000;
        }
        $this->latency = doubleval($latency);
        return $this;
    }
523610
public String latencyHistoReport() {
        ByteArrayOutputStream baos= new ByteArrayOutputStream();
        PrintStream pw = null;
        try {
            pw = new PrintStream(baos, false, Charsets.UTF_8.name());
        } catch (UnsupportedEncodingException e) {
            Throwables.propagate(e);
        }

        //Get a latency report in milliseconds
        m_latencyHistogram.outputPercentileDistributionVolt(pw, 1, 1000.0);

        return new String(baos.toByteArray(), Charsets.UTF_8);
    }
198393
function gossipLastMessageAtFixedInterval(){
    if(p_phase_timeout >0 && Date.now() - p_phase_timeout > constants.BYZANTINE_PHASE_TIMEOUT){

        if(bByzantineUnderWay && last_prevote_gossip &&
            typeof last_prevote_gossip !== 'undefined' &&
            Object.keys(last_prevote_gossip).length > 0){
            if(last_prevote_gossip.type === constants.BYZANTINE_PREVOTE && h_p === last_prevote_gossip.h){
                // console.log("byllllogg gossipLastMessageAtFixedInterval broadcastPrevote" + JSON.stringify(last_prevote_gossip));
                broadcastPrevote(last_prevote_gossip.h, last_prevote_gossip.p, last_prevote_gossip.idv);
            }
        }
        if(bByzantineUnderWay && last_precommit_gossip &&
            typeof last_precommit_gossip !== 'undefined' &&
            Object.keys(last_precommit_gossip).length > 0){
            if(last_precommit_gossip.type === constants.BYZANTINE_PRECOMMIT && h_p === last_precommit_gossip.h){
                if(last_precommit_gossip.idv !== null && assocByzantinePhase[last_precommit_gossip.h].phase[last_precommit_gossip.p].proposal
                    && typeof assocByzantinePhase[last_precommit_gossip.h].phase[last_precommit_gossip.p].proposal !== 'undefined'){
                    var lastProposal = assocByzantinePhase[last_precommit_gossip.h].phase[last_precommit_gossip.p].proposal;
                    broadcastProposal(last_precommit_gossip.h, last_precommit_gossip.p, lastProposal, lastProposal.vp);
                }
                // console.log("byllllogg gossipLastMessageAtFixedInterval broadcastPrecommit" + JSON.stringify(last_precommit_gossip));
                broadcastPrecommit(last_precommit_gossip.h, last_precommit_gossip.p, last_precommit_gossip.sig, last_precommit_gossip.idv);
            }        
        }
    }
}
571665
public static void queuePacket(Packet packet){
        if(isEnabled){
            if(LOGGER.isDebugEnabled()){
                LOGGER.debug("queue packet latency = " + (System.currentTimeMillis() - packet.getCreateTime()));
            }
        }
    }
679047
function defer(cb) {
    if (storage.LATENCY === 0 && typeof process !== 'undefined') {
      process.nextTick(cb);
    } else {
      setTimeout(cb, storage.LATENCY);
    }
  }
1120261
void updateScores() {
    for (LatencyAwareHClientPool pool : allPools) {
      scores.put(pool, pool.score());
      pool.resetIntervel();
    }
  }
814408
public final Latency withMedian(double value) {
    double newValue = value;
    return new Latency(
        newValue,
        this.percentile98th,
        this.percentile99th,
        this.percentile999th,
        this.mean,
        this.min,
        this.max);
  }
1298891
function waitTimeoutNotice() {
        var hangModules = [];
        var missModules = [];
        var missModulesMap = {};
        var hasError;

        for ( var id in modModules ) {
            if ( !modIsDefined( id ) ) {
                hasError = 1;
                hangModules.push( id );
            }

            each(
                modModules[ id ].depMs || [],
                function ( dep ) {
                    var depId = dep.absId;
                    if ( !modModules[ depId ] && !missModulesMap[ depId ] ) {
                        hasError = 1;
                        missModules.push( depId );
                        missModulesMap[ depId ] = 1;
                    }
                }
            );
        }

        if ( hasError ) {
            throw new Error( '[MODULE_TIMEOUT]Hang( '
                + ( hangModules.join( ', ' ) || 'none' )
                + ' ) Miss( '
                + ( missModules.join( ', ' ) || 'none' )
                + ' )'
            );
        }
    }
828415
def latency(self, significant_digits=3):
        
        try:
            end = 'stream' in self._timestamps and 'stream' or 'receive'
            return round(self._timestamps[end] - self._timestamps['send'],
                         significant_digits)
        except Exception as e:
            return None
1031528
def latency(self):
        
        with self.lock:
            self.send('PING %s' % self.server)
            ctime = self._m_time.time()

            msg = self._recv(expected_replies=('PONG',))
            if msg[0] == 'PONG':
                latency = self._m_time.time() - ctime
                return latency