*/
public final class SubSecondTimeWithUnitFormat extends Format {
-
private static final long serialVersionUID = -5147827135781459548L;
private static final String SECONDS = "s"; //$NON-NLS-1$
private static final int NANOS_PER_MILLI = 1000000;
private static final int NANOS_PER_MICRO = 1000;
- private final DecimalFormat fDecimalFormat = new DecimalFormat("#.###"); //$NON-NLS-1$
+ private final DecimalFormat fDecimalFormat = new DecimalFormat("#.000"); //$NON-NLS-1$
@Override
public Object parseObject(@Nullable String source, @Nullable ParsePosition pos) {
final @Nullable StringBuffer appender = toAppendTo;
if ((obj != null) && (obj instanceof Double || obj instanceof Long)) {
double formattedTime = obj instanceof Long ? ((Long) obj).doubleValue() : ((Double) obj).doubleValue();
+ if (Double.isNaN(formattedTime)) {
+ return appender == null ? new StringBuffer() : NonNullUtils.checkNotNull(appender.append("---")); //$NON-NLS-1$
+ }
String unit = NANOSECONDS;
if (formattedTime > NANOS_PER_SEC) {
unit = SECONDS;
unit = MICROSECONDS;
formattedTime /= NANOS_PER_MICRO;
}
- String timeString = fDecimalFormat.format(formattedTime);
+ String timeString = unit.equals(NANOSECONDS) ? Long.toString((long) formattedTime) : fDecimalFormat.format(formattedTime);
return appender == null ? new StringBuffer() : NonNullUtils.checkNotNull(appender.append(timeString).append(' ').append(unit));
}
return new StringBuffer();
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.SubSecondTimeWithUnitFormat;
import org.eclipse.tracecompass.internal.analysis.timing.core.segmentstore.statistics.SegmentStoreStatistics;
import org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfTreeViewerEntry;
/**
- * An abstract tree viewer implementation for displaying segment store statistics
+ * An abstract tree viewer implementation for displaying segment store
+ * statistics
*
* @author Bernd Hufmann
*
private static final Format FORMATTER = new SubSecondTimeWithUnitFormat();
- @Nullable private TmfAbstractAnalysisModule fModule;
+ @Nullable
+ private TmfAbstractAnalysisModule fModule;
private static final String[] COLUMN_NAMES = new String[] {
checkNotNull(Messages.SegmentStoreStatistics_LevelLabel),
checkNotNull(Messages.SegmentStoreStatistics_Statistics_MinLabel),
checkNotNull(Messages.SegmentStoreStatistics_MaxLabel),
- checkNotNull(Messages.SegmentStoreStatistics_AverageLabel)
+ checkNotNull(Messages.SegmentStoreStatistics_AverageLabel),
+ checkNotNull(Messages.SegmentStoreStatisticsViewer_StandardDeviation)
};
/**
@Override
public String getColumnText(@Nullable Object element, int columnIndex) {
- String value = ""; //$NON-NLS-1$
+ String value = ""; //$NON-NLS-1$
if (element instanceof HiddenTreeViewerEntry) {
if (columnIndex == 0) {
value = ((HiddenTreeViewerEntry) element).getName();
value = String.valueOf(toFormattedString(entry.getEntry().getMax()));
} else if (columnIndex == 3) {
value = String.valueOf(toFormattedString(entry.getEntry().getAverage()));
+ } else if (columnIndex == 4) {
+ value = String.valueOf(toFormattedString(entry.getEntry().getStdDev()));
}
}
}
*
* @return the statistics analysis module
*/
- @Nullable protected abstract TmfAbstractAnalysisModule createStatisticsAnalysiModule();
+ @Nullable
+ protected abstract TmfAbstractAnalysisModule createStatisticsAnalysiModule();
/**
* Gets the statistics analysis module
+ *
* @return the statistics analysis module
*/
- @Nullable public TmfAbstractAnalysisModule getStatisticsAnalysisModule() {
+ @Nullable
+ public TmfAbstractAnalysisModule getStatisticsAnalysisModule() {
return fModule;
}
/* All columns are sortable */
List<@Nullable TmfTreeColumnData> columns = new ArrayList<>();
TmfTreeColumnData column = new TmfTreeColumnData(COLUMN_NAMES[0]);
+ column.setAlignment(SWT.RIGHT);
column.setComparator(new ViewerComparator() {
@Override
public int compare(@Nullable Viewer viewer, @Nullable Object e1, @Nullable Object e2) {
});
columns.add(column);
column = new TmfTreeColumnData(COLUMN_NAMES[1]);
+ column.setAlignment(SWT.RIGHT);
column.setComparator(new ViewerComparator() {
@Override
public int compare(@Nullable Viewer viewer, @Nullable Object e1, @Nullable Object e2) {
});
columns.add(column);
column = new TmfTreeColumnData(COLUMN_NAMES[2]);
+ column.setAlignment(SWT.RIGHT);
column.setComparator(new ViewerComparator() {
@Override
public int compare(@Nullable Viewer viewer, @Nullable Object e1, @Nullable Object e2) {
});
columns.add(column);
column = new TmfTreeColumnData(COLUMN_NAMES[3]);
+ column.setAlignment(SWT.RIGHT);
column.setComparator(new ViewerComparator() {
@Override
public int compare(@Nullable Viewer viewer, @Nullable Object e1, @Nullable Object e2) {
}
});
columns.add(column);
+ column = new TmfTreeColumnData(COLUMN_NAMES[4]);
+ column.setAlignment(SWT.RIGHT);
+ column.setComparator(new ViewerComparator() {
+ @Override
+ public int compare(@Nullable Viewer viewer, @Nullable Object e1, @Nullable Object e2) {
+ if ((e1 == null) || (e2 == null)) {
+ return 0;
+ }
+
+ SegmentStoreStatisticsEntry n1 = (SegmentStoreStatisticsEntry) e1;
+ SegmentStoreStatisticsEntry n2 = (SegmentStoreStatisticsEntry) e2;
+ return Double.compare(n1.getEntry().getStdDev(), n2.getEntry().getStdDev());
+
+ }
+ });
+ columns.add(column);
+ column = new TmfTreeColumnData(""); //$NON-NLS-1$
+ columns.add(column);
return columns;
}
};
}
-
@Override
public void initializeDataSource() {
/* Should not be called while trace is still null */
* @return formatted value
*/
protected static String toFormattedString(double value) {
- // The cast to long is needed because the formatter cannot truncate the number.
+ // The cast to long is needed because the formatter cannot truncate the
+ // number.
String percentageString = checkNotNull(String.format("%s", FORMATTER.format(value))); //$NON-NLS-1$
return percentageString;
}