Request / Response statistics apdex_threshold: Thresold for apdex calculation, in milliseconds 50 (ms) by default
513745
function swsReqResStats(apdex_threshold) {
    this.requests=0;                // Total number of requests received
    this.responses=0;               // Total number of responses sent
    this.errors=0;                  // Total number of error responses
    this.info=0;                    // Total number of informational responses
    this.success=0;                 // Total number of success responses
    this.redirect=0;                // Total number of redirection responses
    this.client_error=0;            // Total number of client error responses
    this.server_error=0;            // Total number of server error responses
    this.total_time=0;              // Sum of total processing time (from request received to response finished)
    this.max_time=0;                // Maximum observed processed time
    this.avg_time=0;                // Average processing time
    this.total_req_clength=0;       // Total (Sum) of Content Lengths of received requests
    this.max_req_clength=0;         // Maximum observed Content length in received requests
    this.avg_req_clength=0;         // Average Content Length in received requests
    this.total_res_clength=0;       // Total (Sum) of Content Lengths of sent responses
    this.max_res_clength=0;         // Maximum observed Content Length in sent responses
    this.avg_res_clength=0;         // Average Content Length in sent responses
    this.req_rate=0;                // Request Rate
    this.err_rate=0;                // Error Rate
    this.apdex_threshold = typeof apdex_threshold !== 'undefined' ? apdex_threshold : 50;   // Apdex threshold
    this.apdex_satisfied = 0;       // Total number of "satisfied" responses for Apdex: time <= apdex_threshold
    this.apdex_tolerated = 0;       // Total number of "tolerated" responses for Apdex: time <= (apdex_threshold*4)
    this.apdex_score = 0;           // Apdex score: (apdex_satisfied + (apdex_tolerated/2))/responses
    // TODO Consider: counts by exact response code
}
1142403
def get_latency_average_percentile(self):
        
        (_, _, time_interval) = self.recurrent_works[21]
        last_time = time.time() - time_interval
        latencies = [s.latency for s in self.services if s.last_chk > last_time]
        lat_avg, lat_min, lat_max = average_percentile(latencies)
        if lat_avg is not None:
            self.stats['latency']['avg'] = lat_avg
            self.stats['latency']['min'] = lat_min
            self.stats['latency']['max'] = lat_max
            logger.debug("Latency (avg/min/max): %.2f/%.2f/%.2f", lat_avg, lat_min, lat_max)
710865
def getIRThreshold(self):
    """"""
    command = '$GO'
    threshold = self.sendCommand(command)
    if threshold[0] == 'NK':
      return 0
    else:
      return float(threshold[2])/10
883552
private static void getStats(
      StatsSnapshot snapshot,
      AggregationData data,
      View view,
      ViewData.AggregationWindowData windowData) {
    if (view == RPC_CLIENT_ROUNDTRIP_LATENCY_VIEW || view == RPC_SERVER_SERVER_LATENCY_VIEW) {
      snapshot.avgLatencyTotal = ((DistributionData) data).getMean();
    } else if (view == RPC_CLIENT_ROUNDTRIP_LATENCY_MINUTE_VIEW
        || view == RPC_SERVER_SERVER_LATENCY_MINUTE_VIEW) {
      snapshot.avgLatencyLastMinute = ((AggregationData.MeanData) data).getMean();
    } else if (view == RPC_CLIENT_ROUNDTRIP_LATENCY_HOUR_VIEW
        || view == RPC_SERVER_SERVER_LATENCY_HOUR_VIEW) {
      snapshot.avgLatencyLastHour = ((AggregationData.MeanData) data).getMean();
    } else if (view == RPC_CLIENT_ERROR_COUNT_VIEW || view == RPC_SERVER_ERROR_COUNT_VIEW) {
      snapshot.errorsTotal = ((AggregationData.MeanData) data).getCount();
    } else if (view == RPC_CLIENT_ERROR_COUNT_MINUTE_VIEW
        || view == RPC_SERVER_ERROR_COUNT_MINUTE_VIEW) {
      snapshot.errorsLastMinute = ((AggregationData.MeanData) data).getCount();
    } else if (view == RPC_CLIENT_ERROR_COUNT_HOUR_VIEW
        || view == RPC_SERVER_ERROR_COUNT_HOUR_VIEW) {
      snapshot.errorsLastHour = ((AggregationData.MeanData) data).getCount();
    } else if (view == RPC_CLIENT_REQUEST_BYTES_VIEW || view == RPC_SERVER_REQUEST_BYTES_VIEW) {
      DistributionData distributionData = (DistributionData) data;
      snapshot.inputRateTotal =
          distributionData.getCount()
              * distributionData.getMean()
              / BYTES_PER_KB
              / getDurationInSecs((ViewData.AggregationWindowData.CumulativeData) windowData);
    } else if (view == RPC_CLIENT_REQUEST_BYTES_MINUTE_VIEW
        || view == RPC_SERVER_REQUEST_BYTES_MINUTE_VIEW) {
      AggregationData.MeanData meanData = (AggregationData.MeanData) data;
      snapshot.inputRateLastMinute =
          meanData.getMean() * meanData.getCount() / BYTES_PER_KB / SECONDS_PER_MINUTE;
    } else if (view == RPC_CLIENT_REQUEST_BYTES_HOUR_VIEW
        || view == RPC_SERVER_REQUEST_BYTES_HOUR_VIEW) {
      AggregationData.MeanData meanData = (AggregationData.MeanData) data;
      snapshot.inputRateLastHour =
          meanData.getMean() * meanData.getCount() / BYTES_PER_KB / SECONDS_PER_HOUR;
    } else if (view == RPC_CLIENT_RESPONSE_BYTES_VIEW || view == RPC_SERVER_RESPONSE_BYTES_VIEW) {
      DistributionData distributionData = (DistributionData) data;
      snapshot.outputRateTotal =
          distributionData.getCount()
              * distributionData.getMean()
              / BYTES_PER_KB
              / getDurationInSecs((ViewData.AggregationWindowData.CumulativeData) windowData);
    } else if (view == RPC_CLIENT_RESPONSE_BYTES_MINUTE_VIEW
        || view == RPC_SERVER_RESPONSE_BYTES_MINUTE_VIEW) {
      AggregationData.MeanData meanData = (AggregationData.MeanData) data;
      snapshot.outputRateLastMinute =
          meanData.getMean() * meanData.getCount() / BYTES_PER_KB / SECONDS_PER_MINUTE;
    } else if (view == RPC_CLIENT_RESPONSE_BYTES_HOUR_VIEW
        || view == RPC_SERVER_RESPONSE_BYTES_HOUR_VIEW) {
      AggregationData.MeanData meanData = (AggregationData.MeanData) data;
      snapshot.outputRateLastHour =
          meanData.getMean() * meanData.getCount() / BYTES_PER_KB / SECONDS_PER_HOUR;
    } else if (view == RPC_CLIENT_STARTED_COUNT_MINUTE_VIEW
        || view == RPC_SERVER_STARTED_COUNT_MINUTE_VIEW) {
      snapshot.countLastMinute = ((CountData) data).getCount();
      snapshot.rpcRateLastMinute = snapshot.countLastMinute / SECONDS_PER_MINUTE;
    } else if (view == RPC_CLIENT_STARTED_COUNT_HOUR_VIEW
        || view == RPC_SERVER_STARTED_COUNT_HOUR_VIEW) {
      snapshot.countLastHour = ((CountData) data).getCount();
      snapshot.rpcRateLastHour = snapshot.countLastHour / SECONDS_PER_HOUR;
    } else if (view == RPC_CLIENT_STARTED_COUNT_CUMULATIVE_VIEW
        || view == RPC_SERVER_STARTED_COUNT_CUMULATIVE_VIEW) {
      snapshot.countTotal = ((CountData) data).getCount();
      snapshot.rpcRateTotal =
          snapshot.countTotal
              / getDurationInSecs((ViewData.AggregationWindowData.CumulativeData) windowData);
    } // TODO(songya): compute and store latency percentiles.
  }
966828
def timing(self, stat, time, sample_rate=1):
        
        stats = {stat: "%f|ms" % time}
        self.send(stats, sample_rate)
147650
static long getCheckpointTxnCount(Configuration conf) {
    long defaultCount = 700000;
    long bytesPerTxn = 100;

    return conf.getLong("fs.checkpoint.txns",
        conf.getLong("fs.checkpoint.size", defaultCount * bytesPerTxn)
            / bytesPerTxn);
  }
1028371
def rate_limit_status(self):
        
        return bind_api(
            api=self,
            path='/application/rate_limit_status.json',
            payload_type='json',
            allowed_param=['resources'],
            use_cache=False
        )
333599
def update_stats(self, responses, no_responses):
        
        slowest_rtt = 0.0
        slowest_ip  = None
        fastest_rtt = 9999999.9
        fastest_ip  = None
        rtt_total   = 0.0

        for ip, rtt in responses.items():
            rtt_total += rtt
            if rtt > slowest_rtt:
                slowest_rtt = rtt
                slowest_ip  = ip
            elif rtt < fastest_rtt:
                fastest_rtt = rtt
                fastest_ip  = ip

        sorted_rtts = sorted(responses.values())
        l           = len(sorted_rtts)
        if l == 0:
            median_rtt = 0.0
        elif l % 2 == 1:
            # Odd number: Median is the middle element
            median_rtt = sorted_rtts[int(l / 2)]
        else:
            # Even number (average between two middle elements)
            median_rtt = (sorted_rtts[int(l / 2) - 1] +
                          sorted_rtts[int(l / 2)]) / 2.0

        now = datetime.datetime.now().isoformat()
        m = {
            "time" : now,
            "num_responses" : len(responses),
            "num_no_responses" : len(no_responses),
            "slowest" : {
                "ip"  : slowest_ip,
                "rtt" : slowest_rtt
            },
            "fastest" : {
                "ip"  : fastest_ip,
                "rtt" : fastest_rtt
            },
            "average_rtt" : rtt_total / len(responses),
            "median_rtt" : median_rtt
        }

        self.measurements.insert(0, m)
        self.measurements = self.measurements[:self.max_num_measurements]
664509
function() {
      var timings = {};
      var requests = win.performance.getEntriesByType("resource");
      for (var i = 0; i < requests.length; i++)
        timings[requests[i].name] = requests[i].responseEnd;
      for (var j = 0; j < rects.length; j++) {
        if (!('tm' in rects[j]))
          rects[j].tm = timings[rects[j].url] !== undefined ? timings[rects[j].url] : 0;
      }
    }
302733
def _patch_stats_request(request):
    '''
    '''
    filt = request.get('filter', {})
    if not filt.get('config', None):
        request['filter'] = filters.date_range('acquired',
                                               gt='1970-01-01T00:00:00Z')
    return request
766389
def __get_total_response_time(meta_datas_expanded):
    
    try:
        response_time = 0
        for meta_data in meta_datas_expanded:
            response_time += meta_data["stat"]["response_time_ms"]

        return "{:.2f}".format(response_time)

    except TypeError:
        # failure exists
        return "N/A"
914096
function apiDefaults() {
  return {
    parallelism: 5,
    bufferSize: 500,
    requestTimeout: 120000,
    log: tmp.fileSync().name,
    resume: false,
    mode: 'full'
  };
}
1357723
def _display(self, sent, now, chunk, mbps):
        
        if self.parent is not None:
            self.parent._display(self.parent.offset + sent, now, chunk, mbps)
            return

        elapsed = now - self.startTime

        if sent > 0 and self.total is not None and sent <= self.total:
            eta = (self.total - sent) * elapsed.total_seconds() / sent
            eta = datetime.timedelta(seconds=eta)
        else:
            eta = None

        self.output.write(
            "\r %s: Sent %s%s%s ETA: %s (%s) %s%20s\r" % (
                elapsed,
                util.humanize(sent),
                "" if self.total is None else " of %s" % (util.humanize(self.total),),
                "" if self.total is None else " (%d%%)" % (int(100 * sent / self.total),),
                eta,
                "" if not mbps else "%.3g Mbps " % (mbps,),
                chunk or "",
                " ",
            )
        )

        self.output.flush()
627855
def timing(self, stat, delta, rate=1):
        """"""
        return self.send(stat, "%d|ms" % delta, rate)
567921
def _update_xmit_period(self):
        
        # RFC5880 Section 6.8.7.
        if self._desired_min_tx_interval > self._remote_min_rx_interval:
            xmit_period = self._desired_min_tx_interval
        else:
            xmit_period = self._remote_min_rx_interval

        # This updates the transmission period of BFD Control packets.
        # (RFC5880 Section 6.8.2 & 6.8.3.)
        if self._detect_mult == 1:
            xmit_period *= random.randint(75, 90) / 100.0
        else:
            xmit_period *= random.randint(75, 100) / 100.0

        self._xmit_period = xmit_period / 1000000.0
        LOG.info("[BFD][%s][XMIT] Transmission period changed to %f",
                 hex(self._local_discr), self._xmit_period)
633483
def requestPdpContextActivationReject():
    """"""
    a = TpPd(pd=0x8)
    b = MessageType(mesType=0x45)  # 01000101
    c = SmCause()
    packet = a / b / c
    return packet
348865
def _delay_for_ratelimits(cls, start):
        """"""
        stop = datetime.now()
        duration_microseconds = (stop - start).microseconds
        if duration_microseconds < cls.REQUEST_TIME_MICROSECONDS:
            time.sleep((cls.REQUEST_TIME_MICROSECONDS - duration_microseconds)
                       / MICROSECONDS_PER_SECOND)