com.yammer.metrics.core.Timer.durationUnit()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(122)

本文整理了Java中com.yammer.metrics.core.Timer.durationUnit()方法的一些代码示例,展示了Timer.durationUnit()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Timer.durationUnit()方法的具体详情如下:
包路径:com.yammer.metrics.core.Timer
类名称:Timer
方法名:durationUnit

Timer.durationUnit介绍

[英]Returns the timer's duration scale unit.
[中]返回计时器的持续时间刻度单位。

代码示例

代码示例来源:origin: com.yammer.metrics/metrics-core

@Override
public TimeUnit getLatencyUnit() {
  return metric.durationUnit();
}

代码示例来源:origin: wavefrontHQ/java

@Override
 public void processTimer(MetricName name, Timer timer, Context context) throws Exception {
  final JsonGenerator json = context.json;
  json.writeStartObject();
  {
   json.writeFieldName("duration");
   json.writeStartObject();
   {
    json.writeStringField("unit", timer.durationUnit().toString().toLowerCase());
    writeSummarizable(timer, json);
    writeSampling(timer, json);
    if (context.showFullSamples) {
     json.writeObjectField("values", timer.getSnapshot().getValues());
    }
   }
   json.writeEndObject();
   json.writeFieldName("rate");
   json.writeStartObject();
   {
    writeMeteredFields(timer, json);
   }
   json.writeEndObject();
  }
  json.writeEndObject();
  if (clear) timer.clear();
 }
}

代码示例来源:origin: com.wavefront/java-lib

@Override
 public void processTimer(MetricName name, Timer timer, Context context) throws Exception {
  final JsonGenerator json = context.json;
  json.writeStartObject();
  {
   json.writeFieldName("duration");
   json.writeStartObject();
   {
    json.writeStringField("unit", timer.durationUnit().toString().toLowerCase());
    writeSummarizable(timer, json);
    writeSampling(timer, json);
    if (context.showFullSamples) {
     json.writeObjectField("values", timer.getSnapshot().getValues());
    }
   }
   json.writeEndObject();
   json.writeFieldName("rate");
   json.writeStartObject();
   {
    writeMeteredFields(timer, json);
   }
   json.writeEndObject();
  }
  json.writeEndObject();
  if (clear) timer.clear();
 }
}

代码示例来源:origin: com.yammer.metrics/metrics-servlet

@Override
public void processTimer(MetricName name, Timer timer, Context context) throws Exception {
  final JsonGenerator json = context.json;
  json.writeStartObject();
  {
    json.writeStringField("type", "timer");
    json.writeFieldName("duration");
    json.writeStartObject();
    {
      json.writeStringField("unit", timer.durationUnit().toString().toLowerCase());
      writeSummarizable(timer, json);
      writeSampling(timer, json);
      if (context.showFullSamples) {
        json.writeObjectField("values", timer.getSnapshot().getValues());
      }
    }
    json.writeEndObject();
    json.writeFieldName("rate");
    json.writeStartObject();
    {
      writeMeteredFields(timer, json);
    }
    json.writeEndObject();
  }
  json.writeEndObject();
}

代码示例来源:origin: com.yammer.metrics/metrics-core

@Override
public void processTimer(MetricName name, Timer timer, PrintStream stream) {
  processMeter(name, timer, stream);
  final String durationUnit = abbrev(timer.durationUnit());
  final Snapshot snapshot = timer.getSnapshot();
  stream.printf(locale, "               min = %2.2f%s\n", timer.min(), durationUnit);
  stream.printf(locale, "               max = %2.2f%s\n", timer.max(), durationUnit);
  stream.printf(locale, "              mean = %2.2f%s\n", timer.mean(), durationUnit);
  stream.printf(locale, "            stddev = %2.2f%s\n", timer.stdDev(), durationUnit);
  stream.printf(locale, "            median = %2.2f%s\n", snapshot.getMedian(), durationUnit);
  stream.printf(locale, "              75%% <= %2.2f%s\n", snapshot.get75thPercentile(), durationUnit);
  stream.printf(locale, "              95%% <= %2.2f%s\n", snapshot.get95thPercentile(), durationUnit);
  stream.printf(locale, "              98%% <= %2.2f%s\n", snapshot.get98thPercentile(), durationUnit);
  stream.printf(locale, "              99%% <= %2.2f%s\n", snapshot.get99thPercentile(), durationUnit);
  stream.printf(locale, "            99.9%% <= %2.2f%s\n", snapshot.get999thPercentile(), durationUnit);
}

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-server

public void run()
  {
    SpeculativeRetry retryPolicy = ColumnFamilyStore.this.metadata.getSpeculativeRetry();
    switch (retryPolicy.type)
    {
      case PERCENTILE:
        // get percentile in nanos
        assert metric.coordinatorReadLatency.durationUnit() == TimeUnit.MICROSECONDS;
        sampleLatencyNanos = (long) (metric.coordinatorReadLatency.getSnapshot().getValue(retryPolicy.value) * 1000d);
        break;
      case CUSTOM:
        // convert to nanos, since configuration is in millisecond
        sampleLatencyNanos = (long) (retryPolicy.value * 1000d * 1000d);
        break;
      default:
        sampleLatencyNanos = Long.MAX_VALUE;
        break;
    }
  }
}, DatabaseDescriptor.getReadRpcTimeout(), DatabaseDescriptor.getReadRpcTimeout(), TimeUnit.MILLISECONDS);

代码示例来源:origin: addthis/hydra

final Timer timer = mock(Timer.class);
when(timer.eventType()).thenReturn("events");
when(timer.durationUnit()).thenReturn(TimeUnit.MILLISECONDS);
when(timer.rateUnit()).thenReturn(TimeUnit.SECONDS);
when(timer.count()).thenReturn(1L);

代码示例来源:origin: addthis/hydra

@Override
public void processTimer(MetricName name, Timer timer, String x) throws IOException {
  processMeter(name, timer, x);
  final String sanitizedName = sanitizeName(name);
  final Snapshot snapshot = timer.getSnapshot();
  final String durationUnit = timer.durationUnit().name();
  printDoubleField(sanitizedName + ".min", timer.min(), "timer", durationUnit);
  printDoubleField(sanitizedName + ".max", timer.max(), "timer", durationUnit);
  printDoubleField(sanitizedName + ".mean", timer.mean(), "timer", durationUnit);
  printDoubleField(sanitizedName + ".stddev", timer.stdDev(), "timer", durationUnit);
  printDoubleField(sanitizedName + ".median", snapshot.getMedian(), "timer", durationUnit);
  printDoubleField(sanitizedName + ".75percentile", snapshot.get75thPercentile(), "timer", durationUnit);
  printDoubleField(sanitizedName + ".95percentile", snapshot.get95thPercentile(), "timer", durationUnit);
  printDoubleField(sanitizedName + ".98percentile", snapshot.get98thPercentile(), "timer", durationUnit);
  printDoubleField(sanitizedName + ".99percentile", snapshot.get99thPercentile(), "timer", durationUnit);
  printDoubleField(sanitizedName + ".999percentile", snapshot.get999thPercentile(), "timer", durationUnit);
}

相关文章