public AbstractQuantity<?> ownTimeValue() { Preconditions.checkState(endValue != null, "Can't measure time until timer is stopped"); return NumberQuantity.of(ownValueSoFar, metricSource.getUnit()); }
public AbstractQuantity<?> totalValue() { Preconditions.checkState(endValue != null, "Can't measure time until timer is stopped"); return NumberQuantity.of(endValue - startValue, metricSource.getUnit()); }
@SuppressWarnings({ "unchecked", "rawtypes" }) String buildSingleMetricResult(MetricMeasurement metric) { Unit canonicalUnit = normalizations.get(metric.getMetricSource().getUnit()); if (canonicalUnit == null) { canonicalUnit = metric.getMetricSource().getUnit(); } return metric.getMetricName() + ": own " + metric.ownTimeValue().to(canonicalUnit) + ", total " + metric.totalValue().to(canonicalUnit); }
private EventCounters getCounterSet(String eventGroup) { EventMetricCounters invocationCounter = createEventMetricCounters(eventGroup, "count", "Total number of times the event was directly triggered", ONE); EventCounters counters = new EventCounters(invocationCounter, cleanName(eventGroup)); for (ThreadMetric metric : metricSuite.metrics()) { EventMetricCounters timingCounter = createEventMetricCounters(eventGroup, metric .getCounterSuffix(), metric.getDescription(), metric.getUnit()); counters.addMetric(metric, timingCounter); } return counters; }
public void testUnitDisplay() { MetricMeasurement timing = new MetricMeasurement(StandardThreadMetrics.CLOCK_TIME, Thread .currentThread()); timing.startTimer(); timing.stopTimer(); assertTrue("Metric value should end with correct unit name", timing.ownTimeValue().toString() .endsWith(StandardThreadMetrics.CLOCK_TIME.getUnit().toString())); } }