/** * Get the max value since the last reset. */ public Double getMax() { return max.getCurrentValue(0); }
private void recordNanos(long nanos) { if (nanos >= 0) { double amount = nanos * timeUnitNanosFactor; totalTime.increment(amount); count.increment(); totalOfSquares.increment(amount * amount); max.update(amount); } }
/** * {@inheritDoc} */ @Override public void initializeSpectator(TagList tags) { totalTime.initializeSpectator(BasicTagList.concat(tags, STAT_TOTAL)); count.initializeSpectator(BasicTagList.concat(tags, STAT_COUNT)); totalOfSquares.initializeSpectator(BasicTagList.concat(tags, STAT_TOTAL_SQ)); max.initializeSpectator(BasicTagList.concat(tags, STAT_MAX)); }
/** * Update the max if the provided value is larger than the current max. */ public void update(double v) { spectatorGauge.set(v); for (int i = 0; i < Pollers.NUM_POLLERS; ++i) { updateMax(i, v); } }
/** * Creates a new instance of the timer. */ BasicTimer(MonitorConfig config, TimeUnit unit, Clock clock) { super(config); final Tag unitTag = Tags.newTag(UNIT, unit.name()); final MonitorConfig unitConfig = config.withAdditionalTag(unitTag); timeUnit = unit; timeUnitNanosFactor = 1.0 / timeUnit.toNanos(1); totalTime = new DoubleCounter(unitConfig.withAdditionalTag(STAT_TOTAL), clock); count = new StepCounter(unitConfig.withAdditionalTag(STAT_COUNT), clock); totalOfSquares = new DoubleCounter(unitConfig.withAdditionalTag(STAT_TOTAL_SQ), clock); max = new DoubleMaxGauge(unitConfig.withAdditionalTag(STAT_MAX), clock); monitors = UnmodifiableList.<Monitor<?>>of(totalTime, count, totalOfSquares, max); }
/** * {@inheritDoc} */ @Override public int hashCode() { int result = config.hashCode(); result = 31 * result + totalTime.hashCode(); result = 31 * result + count.hashCode(); result = 31 * result + totalOfSquares.hashCode(); result = 31 * result + max.hashCode(); return result; }
/** * {@inheritDoc} */ @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || !(obj instanceof BasicTimer)) { return false; } BasicTimer m = (BasicTimer) obj; return config.equals(m.getConfig()) && totalTime.equals(m.totalTime) && count.equals(m.count) && totalOfSquares.equals(m.totalOfSquares) && max.equals(m.max); }
/** * {@inheritDoc} */ @Override public void initializeSpectator(TagList tags) { totalTime.initializeSpectator(BasicTagList.concat(tags, STAT_TOTAL)); count.initializeSpectator(BasicTagList.concat(tags, STAT_COUNT)); totalOfSquares.initializeSpectator(BasicTagList.concat(tags, STAT_TOTAL_SQ)); max.initializeSpectator(BasicTagList.concat(tags, STAT_MAX)); }
/** * Update the max if the provided value is larger than the current max. */ public void update(double v) { spectatorGauge.set(v); for (int i = 0; i < Pollers.NUM_POLLERS; ++i) { updateMax(i, v); } }
/** * Creates a new instance of the timer. */ BasicTimer(MonitorConfig config, TimeUnit unit, Clock clock) { super(config); final Tag unitTag = Tags.newTag(UNIT, unit.name()); final MonitorConfig unitConfig = config.withAdditionalTag(unitTag); timeUnit = unit; timeUnitNanosFactor = 1.0 / timeUnit.toNanos(1); totalTime = new DoubleCounter(unitConfig.withAdditionalTag(STAT_TOTAL), clock); count = new StepCounter(unitConfig.withAdditionalTag(STAT_COUNT), clock); totalOfSquares = new DoubleCounter(unitConfig.withAdditionalTag(STAT_TOTAL_SQ), clock); max = new DoubleMaxGauge(unitConfig.withAdditionalTag(STAT_MAX), clock); monitors = UnmodifiableList.<Monitor<?>>of(totalTime, count, totalOfSquares, max); }
/** * {@inheritDoc} */ @Override public int hashCode() { int result = config.hashCode(); result = 31 * result + totalTime.hashCode(); result = 31 * result + count.hashCode(); result = 31 * result + totalOfSquares.hashCode(); result = 31 * result + max.hashCode(); return result; }
/** * {@inheritDoc} */ @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || !(obj instanceof BasicTimer)) { return false; } BasicTimer m = (BasicTimer) obj; return config.equals(m.getConfig()) && totalTime.equals(m.totalTime) && count.equals(m.count) && totalOfSquares.equals(m.totalOfSquares) && max.equals(m.max); }
/** * Get the max value since the last reset. */ public Double getMax() { return max.getCurrentValue(0); }
private void recordNanos(long nanos) { if (nanos >= 0) { double amount = nanos * timeUnitNanosFactor; totalTime.increment(amount); count.increment(); totalOfSquares.increment(amount * amount); max.update(amount); } }