@Override public boolean matches(Object argument) { if (!DatabaseAggregatedTimerData.class.equals(argument.getClass())) { return false; } TimerData timerData = (TimerData) argument; assertThat(timerData.getCount() % count, is(equalTo(0L))); assertThat(timerData.getMin(), is(equalTo(min))); assertThat(timerData.getMax(), is(equalTo(max))); assertThat(timerData.getAverage(), is(equalTo(average))); assertThat(timerData.getDuration() / timerData.getCount(), is(equalTo(average))); assertThat(timerData.getCpuMin(), is(equalTo(min))); assertThat(timerData.getCpuMax(), is(equalTo(max))); assertThat(timerData.getCpuAverage(), is(equalTo(average))); assertThat(timerData.getCpuDuration() / timerData.getCount(), is(equalTo(average))); assertThat(timerData.getExclusiveMin(), is(equalTo(min))); assertThat(timerData.getExclusiveMax(), is(equalTo(max))); assertThat(timerData.getExclusiveAverage(), is(equalTo(average))); return true; } }));
assertThat(timerData.getCpuDuration(), is((secondCpuTimerValue - firstCpuTimerValue) / 1000000.0d)); assertThat(timerData.getCpuMin(), is((secondCpuTimerValue - firstCpuTimerValue) / 1000000.0d)); assertThat(timerData.getCpuMax(), is((secondCpuTimerValue - firstCpuTimerValue) / 1000000.0d)); assertThat(timerData.isCharting(), is(true));
assertThat(timerData.getCpuDuration(), is((thirdCpuTimerValue - secondCpuTimerValue) / 1000000.0d)); assertThat(timerData.getCpuMin(), is((thirdCpuTimerValue - secondCpuTimerValue) / 1000000.0d)); assertThat(timerData.getCpuMax(), is((thirdCpuTimerValue - secondCpuTimerValue) / 1000000.0d)); assertThat(timerData.isCharting(), is(false)); assertThat(timerData.getCpuDuration(), is((fourthCpuTimerValue - firstCpuTimerValue) / 1000000.0d)); assertThat(timerData.getCpuMin(), is((fourthCpuTimerValue - firstCpuTimerValue) / 1000000.0d)); assertThat(timerData.getCpuMax(), is((fourthCpuTimerValue - firstCpuTimerValue) / 1000000.0d)); assertThat(timerData.isCharting(), is(false));
when(data.getAverage()).thenReturn(RandomUtils.nextDouble()); when(data.getCpuMin()).thenReturn(RandomUtils.nextDouble()); when(data.getCpuMax()).thenReturn(RandomUtils.nextDouble()); when(data.getCpuAverage()).thenReturn(RandomUtils.nextDouble()); assertThat(getFields(pointBuilder), hasEntry(Series.Methods.FIELD_MIN_CPU_TIME, (Object) data.getCpuMin())); assertThat(getFields(pointBuilder), hasEntry(Series.Methods.FIELD_CPU_TIME, (Object) data.getCpuAverage())); assertThat(getFields(pointBuilder), hasEntry(Series.Methods.FIELD_MAX_CPU_TIME, (Object) data.getCpuMax()));
/** * {@inheritDoc} */ @Override protected void addFields(TimerData data, Builder builder) { // fields builder.addField(Series.Methods.FIELD_MIN_DURATION, data.getMin()); builder.addField(Series.Methods.FIELD_DURATION, data.getAverage()); builder.addField(Series.Methods.FIELD_MAX_DURATION, data.getMax()); builder.addField(Series.Methods.FIELD_MIN_CPU_TIME, data.getCpuMin()); builder.addField(Series.Methods.FIELD_CPU_TIME, data.getCpuAverage()); builder.addField(Series.Methods.FIELD_MAX_CPU_TIME, data.getCpuMax()); builder.addField(Series.Methods.FIELD_COUNT, data.getCount()); }
/** * {@inheritDoc} * <p> * This method does not aggregate the {@link InvocationAwareData} because it is not needed in * the database. */ @Override public void aggregateTimerData(TimerData timerData) { this.setCount(this.getCount() + timerData.getCount()); this.setDuration(this.getDuration() + timerData.getDuration()); this.calculateMax(timerData.getMax()); this.calculateMin(timerData.getMin()); if (timerData.isCpuMetricDataAvailable()) { this.setCpuDuration(this.getCpuDuration() + timerData.getCpuDuration()); this.calculateCpuMin(timerData.getCpuMin()); this.calculateCpuMax(timerData.getCpuMax()); } if (timerData.isExclusiveTimeDataAvailable()) { this.addExclusiveDuration(timerData.getExclusiveDuration()); this.setExclusiveCount(this.getExclusiveCount() + timerData.getExclusiveCount()); this.calculateExclusiveMin(timerData.getExclusiveMin()); this.calculateExclusiveMax(timerData.getExclusiveMax()); } } }
/** * Aggregates the values given in the supplied timer data parameter to the objects data. * * @param timerData * Data to be aggregated into current object. */ public void aggregateTimerData(TimerData timerData) { super.aggregateInvocationAwareData(timerData); this.setCount(this.getCount() + timerData.getCount()); this.setDuration(this.getDuration() + timerData.getDuration()); this.calculateMax(timerData.getMax()); this.calculateMin(timerData.getMin()); if (timerData.isCpuMetricDataAvailable()) { this.setCpuDuration(this.getCpuDuration() + timerData.getCpuDuration()); this.calculateCpuMax(timerData.getCpuMax()); this.calculateCpuMin(timerData.getCpuMin()); } if (timerData.isExclusiveTimeDataAvailable()) { this.addExclusiveDuration(timerData.getExclusiveDuration()); this.setExclusiveCount(this.getExclusiveCount() + timerData.getExclusiveCount()); this.calculateExclusiveMax(timerData.getExclusiveMax()); this.calculateExclusiveMin(timerData.getExclusiveMin()); } this.charting = this.charting | timerData.isCharting(); }
return new StyledString(NumberFormatter.formatDouble(data.getCpuMax(), timeDecimalPlaces)); } else { return emptyStyledString;
return new StyledString(NumberFormatter.formatDouble(data.getCpuMax())); } else { return emptyStyledString;
new DetailsCellContent(NumberFormatter.formatDouble(timerData.getCpuMax())) }; table.addContentRow("CPU:", null, cpu);