/** * Aggregate this timerData with the provided timerData. * * @param timerData * timerData of invocationSequenceData to be aggregated */ public void aggregate(TimerData timerData) { this.duration += timerData.getDuration(); this.cpuDuration += timerData.getCpuDuration(); this.exclusiveDuration += timerData.getExclusiveDuration(); this.exclusiveCount += timerData.getExclusiveCount(); }
/** * Default constructor. * * @param timerData * the timerData that is taken into account */ public DiagnosisTimerData(final TimerData timerData) { if (timerData == null) { throw new IllegalArgumentException("TimerData cannot be null!"); } this.duration = timerData.getDuration(); this.cpuDuration = timerData.getCpuDuration(); this.exclusiveDuration = timerData.getExclusiveDuration(); if (timerData instanceof SqlStatementData) { SqlStatementData sqlStatementData = (SqlStatementData) timerData; this.metaData.put(MetaDataType.SQL, sqlStatementData.getSql()); } else if (timerData instanceof HttpTimerData) { HttpTimerData httpTimerData = (HttpTimerData) timerData; this.metaData.put(MetaDataType.URI, httpTimerData.getHttpInfo().getUri()); } }
@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; } }));
return Double.compare(o1.getCpuMax(), o2.getCpuMax()); case CPUDURATION: return Double.compare(o1.getCpuDuration(), o2.getCpuDuration()); case EXCLUSIVEAVERAGE: return Double.compare(o1.getExclusiveAverage(), o2.getExclusiveAverage());
assertThat(timerData.getMin(), is(secondTimerValue - firstTimerValue)); assertThat(timerData.getMax(), is(secondTimerValue - firstTimerValue)); 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.getMin(), is(thirdTimerValue - secondTimerValue)); assertThat(timerData.getMax(), is(thirdTimerValue - secondTimerValue)); 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.getMin(), is(fourthTimerValue - firstTimerValue)); assertThat(timerData.getMax(), is(fourthTimerValue - firstTimerValue)); assertThat(timerData.getCpuDuration(), is((fourthCpuTimerValue - firstCpuTimerValue) / 1000000.0d)); assertThat(timerData.getCpuMin(), is((fourthCpuTimerValue - firstCpuTimerValue) / 1000000.0d)); assertThat(timerData.getCpuMax(), is((fourthCpuTimerValue - firstCpuTimerValue) / 1000000.0d));
/** * {@inheritDoc} */ @Override public DetailsTable generate(DefaultData defaultData, RepositoryDefinition repositoryDefinition, Composite parent, FormToolkit toolkit) { TimerData timerData = (TimerData) defaultData; DetailsTable table = new DetailsTable(parent, toolkit, "Duration Info", 1); // then the total duration DetailsCellContent[] total = new DetailsCellContent[] { new DetailsCellContent(NumberFormatter.formatDouble(timerData.getDuration())) }; table.addContentRow("Total (ms):", null, total); if (timerData.isCpuMetricDataAvailable()) { // then the total duration DetailsCellContent[] cpu = new DetailsCellContent[] { new DetailsCellContent(NumberFormatter.formatDouble(timerData.getCpuDuration())) }; table.addContentRow("CPU (ms):", null, cpu); } if (timerData.isExclusiveTimeDataAvailable()) { // then the exclusive DetailsCellContent[] exclusive = new DetailsCellContent[] { new DetailsCellContent(NumberFormatter.formatDouble(timerData.getExclusiveDuration())) }; table.addContentRow("Exclusive (ms):", null, exclusive); } return table; }
/** * 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(); }
styledString = new StyledString(); if (InvocationSequenceDataHelper.hasTimerData(data) && data.getTimerData().isCpuMetricDataAvailable()) { styledString.append(NumberFormatter.formatDouble(data.getTimerData().getCpuDuration()));
/** * {@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()); } } }
return new StyledString(NumberFormatter.formatDouble(data.getCpuDuration(), timeDecimalPlaces)); } else { return emptyStyledString;
return new StyledString(NumberFormatter.formatDouble(data.getCpuDuration())); } else { return emptyStyledString;