/** * Returns string representation of count and percentage. * * @param count * Count. * @param totalCount * Total count. * @return {@link String} representation. */ private String getCountAndPercentage(int count, int totalCount) { if (0 == totalCount) { return "0(0%)"; } return count + "(" + NumberFormatter.formatDouble(((double) count / totalCount) * 100, 0) + "%)"; }
/** * Returns styled text for {@link Span} based on the column. * * @param span * span * @param enumId * column * @return string */ public StyledString getStyledTextForColumn(Span span, Column enumId) { switch (enumId) { case ELEMENT: return TextFormatter.getSpanDetailsFull(span, cachedDataService); case DURATION: return new StyledString(NumberFormatter.formatDouble(span.getDuration())); default: return new StyledString(); } }
/** * {@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; }
totalDuration.setText("<form><p><b>" + TOTAL_DURATION + "</b> " + NumberFormatter.formatDouble(duration.doubleValue()) + " ms</p></form>", true, false); String formatedPercentage = NumberFormatter.formatDouble(percentage, 1); if (CollectionUtils.isNotEmpty(sqlList)) { Color durationInInvocationColor = ColorFormatter.getPerformanceColor(GREEN_RGB, YELLOW_RGB, RED_RGB, percentage, 20d, 80d, resourceManager);
return new StyledString(Long.toString(data.getCount())); case AVERAGE: return new StyledString(NumberFormatter.formatDouble(data.getAverage())); case MIN: return new StyledString(NumberFormatter.formatDouble(data.getMin())); case MAX: return new StyledString(NumberFormatter.formatDouble(data.getMax())); case DURATION: return new StyledString(NumberFormatter.formatDouble(data.getDuration())); case EXCLUSIVEAVERAGE: if (data.isExclusiveTimeDataAvailable()) { return new StyledString(NumberFormatter.formatDouble(data.getExclusiveAverage())); } else { return new StyledString(""); return new StyledString(NumberFormatter.formatDouble(data.getExclusiveMax())); } else { return new StyledString(""); return new StyledString(NumberFormatter.formatDouble(data.getExclusiveMin())); } else { return new StyledString("");
return new StyledString(Long.toString(data.getCount())); case AVERAGE: return new StyledString(NumberFormatter.formatDouble(data.getAverage(), timeDecimalPlaces)); case MIN: return new StyledString(NumberFormatter.formatDouble(data.getMin(), timeDecimalPlaces)); case MAX: return new StyledString(NumberFormatter.formatDouble(data.getMax(), timeDecimalPlaces)); case DURATION: return new StyledString(NumberFormatter.formatDouble(data.getDuration(), timeDecimalPlaces)); default: return new StyledString("error");
new DetailsCellContent(NumberFormatter.formatDouble(timerData.getAverage())), new DetailsCellContent(NumberFormatter.formatDouble(timerData.getMin())), new DetailsCellContent(NumberFormatter.formatDouble(timerData.getMax())) }; table.addContentRow("Total:", null, total); new DetailsCellContent(NumberFormatter.formatDouble(timerData.getCpuAverage())), new DetailsCellContent(NumberFormatter.formatDouble(timerData.getCpuMin())), new DetailsCellContent(NumberFormatter.formatDouble(timerData.getCpuMax())) }; table.addContentRow("CPU:", null, cpu); new DetailsCellContent(NumberFormatter.formatDouble(timerData.getExclusiveAverage())), new DetailsCellContent(NumberFormatter.formatDouble(timerData.getExclusiveMin())), new DetailsCellContent(NumberFormatter.formatDouble(timerData.getExclusiveMax())) }; table.addContentRow("Exclusive:", null, exclusive);
return new StyledString(Long.toString(data.getCount())); case AVERAGE: return new StyledString(NumberFormatter.formatDouble(data.getAverage(), timeDecimalPlaces)); case MIN: return new StyledString(NumberFormatter.formatDouble(data.getMin(), timeDecimalPlaces)); case MAX: return new StyledString(NumberFormatter.formatDouble(data.getMax(), timeDecimalPlaces)); case DURATION: return new StyledString(NumberFormatter.formatDouble(data.getDuration(), timeDecimalPlaces)); case PREPARED: if (data.isPreparedStatement()) {
case AVERAGE: if (data.isTimeDataAvailable()) { return new StyledString(NumberFormatter.formatDouble(data.getAverage(), timeDecimalPlaces)); } else { return emptyStyledString; return new StyledString(NumberFormatter.formatDouble(data.getMin(), timeDecimalPlaces)); } else { return emptyStyledString; return new StyledString(NumberFormatter.formatDouble(data.getMax(), timeDecimalPlaces)); } else { return emptyStyledString; return new StyledString(NumberFormatter.formatDouble(data.getDuration(), timeDecimalPlaces)); } else { return emptyStyledString; return new StyledString(NumberFormatter.formatDouble(data.getCpuAverage(), timeDecimalPlaces)); } else { return emptyStyledString; return new StyledString(NumberFormatter.formatDouble(data.getCpuMin(), timeDecimalPlaces)); } else { return emptyStyledString; return new StyledString(NumberFormatter.formatDouble(data.getCpuMax(), timeDecimalPlaces)); } else { return emptyStyledString;
case AVERAGE: if (data.isTimeDataAvailable()) { return new StyledString(NumberFormatter.formatDouble(data.getAverage(), timeDecimalPlaces)); } else { return emptyStyledString; return new StyledString(NumberFormatter.formatDouble(data.getMin(), timeDecimalPlaces)); } else { return emptyStyledString; return new StyledString(NumberFormatter.formatDouble(data.getMax(), timeDecimalPlaces)); } else { return emptyStyledString; return new StyledString(NumberFormatter.formatDouble(data.getDuration(), timeDecimalPlaces)); } else { return emptyStyledString; return new StyledString(NumberFormatter.formatDouble(data.getCpuAverage(), timeDecimalPlaces)); } else { return emptyStyledString; return new StyledString(NumberFormatter.formatDouble(data.getCpuMin(), timeDecimalPlaces)); } else { return emptyStyledString; return new StyledString(NumberFormatter.formatDouble(data.getCpuMax(), timeDecimalPlaces)); } else { return emptyStyledString;
case AVERAGE: if (data.isTimeDataAvailable()) { return new StyledString(NumberFormatter.formatDouble(data.getAverage(), timeDecimalPlaces)); } else { return emptyStyledString; return new StyledString(NumberFormatter.formatDouble(data.getMin(), timeDecimalPlaces)); } else { return emptyStyledString; return new StyledString(NumberFormatter.formatDouble(data.getMax(), timeDecimalPlaces)); } else { return emptyStyledString; return new StyledString(NumberFormatter.formatDouble(data.getDuration(), timeDecimalPlaces)); } else { return emptyStyledString; return new StyledString(NumberFormatter.formatDouble(data.getCpuAverage(), timeDecimalPlaces)); } else { return emptyStyledString; return new StyledString(NumberFormatter.formatDouble(data.getCpuMin(), timeDecimalPlaces)); } else { return emptyStyledString; return new StyledString(NumberFormatter.formatDouble(data.getCpuMax(), timeDecimalPlaces)); } else { return emptyStyledString;
return new StyledString(Long.toString(data.getCount())); case AVERAGE: return new StyledString(NumberFormatter.formatDouble(data.getAverage())); case MIN: return new StyledString(NumberFormatter.formatDouble(data.getMin())); case MAX: return new StyledString(NumberFormatter.formatDouble(data.getMax())); case DURATION: return new StyledString(NumberFormatter.formatDouble(data.getDuration())); case PREPARED: if (rawMode) {
return new StyledString(NumberFormatter.formatDouble(data.getAverage())); } else { return emptyStyledString; return new StyledString(NumberFormatter.formatDouble(data.getMin())); } else { return emptyStyledString; return new StyledString(NumberFormatter.formatDouble(data.getMax())); } else { return emptyStyledString; return new StyledString(NumberFormatter.formatDouble(data.getDuration())); } else { return emptyStyledString; return new StyledString(NumberFormatter.formatDouble(data.getCpuAverage())); } else { return emptyStyledString; return new StyledString(NumberFormatter.formatDouble(data.getCpuMin())); } else { return emptyStyledString; return new StyledString(NumberFormatter.formatDouble(data.getCpuMax())); } else { return emptyStyledString; return new StyledString(NumberFormatter.formatDouble(data.getCpuDuration()));
return new StyledString(NumberFormatter.formatTimeWithMillis(span.getTimeStamp())); case DURATION: StyledString durationString = new StyledString(NumberFormatter.formatDouble(span.getDuration(), timeDecimalPlaces)); if (InvocationTreeUtil.isConsideredAsync(ite)) { durationString.append(TextFormatter.getWarningSign()); case EXCLUSIVE: StyledString exclusive = new StyledString(); exclusive.append(NumberFormatter.formatDouble(InvocationTreeUtil.calculateSpanExclusiveDuration(ite), timeDecimalPlaces)); exclusive.append(" (", StyledString.COUNTER_STYLER); int percentage = Math.round((float) InvocationTreeUtil.calculateSpanExclusivePercentage(ite) * 100);
table.addContentRow("Duration (ms):", null, new DetailsCellContent[] { new DetailsCellContent(NumberFormatter.formatDouble(span.getDuration(), 3)) });
/** * Returns the styled text for a specific column. * * @param data * The data object to extract the information from. * @param enumId * The enumeration ID. * @return The styled string containing the information from the data object. */ private StyledString getStyledTextForColumn(Span data, Column enumId) { switch (enumId) { case TIME: return new StyledString(NumberFormatter.formatTimeWithMillis(data.getTimeStamp())); case DURATION: return new StyledString(NumberFormatter.formatDouble(data.getDuration(), timeDecimalPlaces)); case PROPAGATION: return TextFormatter.getPropagationStyled(data.getPropagationType()); case DETAILS: return TextFormatter.getSpanDetailsShort(data, cachedDataService); case ORIGIN: return TextFormatter.getSpanOriginStyled(data, cachedDataService.getPlatformIdentForId(data.getPlatformIdent())); case TRACE_ID: return new StyledString(Long.toHexString(data.getSpanIdent().getTraceId())); default: return new StyledString("error"); } } }
double duration = InvocationSequenceDataHelper.calculateDuration(data, spanService); if (-1.0d != duration) { styledString.append(NumberFormatter.formatDouble(duration)); styledString = new StyledString(); if (InvocationSequenceDataHelper.hasTimerData(data) && data.getTimerData().isCpuMetricDataAvailable()) { styledString.append(NumberFormatter.formatDouble(data.getTimerData().getCpuDuration())); styledString.append(NumberFormatter.formatDouble(exclusiveTime));
case DURATION: if (InvocationSequenceDataHelper.hasTimerData(data)) { return new StyledString(NumberFormatter.formatDouble(data.getTimerData().getDuration())); } else { return new StyledString(NumberFormatter.formatDouble(data.getDuration()));