use of org.eclipse.test.internal.performance.eval.StatisticsSession in project eclipse.platform.releng by eclipse.
the class DB method internalStore.
private boolean internalStore(final Variations variations, final Sample sample) {
if ((fSQL == null) || (sample == null)) {
return false;
}
final DataPoint[] dataPoints = sample.getDataPoints();
final int n = dataPoints.length;
if (n <= 0) {
return false;
}
// System.out.println("store started..."); //$NON-NLS-1$
try {
// long l= System.currentTimeMillis();
final int variation_id = fSQL.getVariations(variations);
final int scenario_id = fSQL.getScenario(sample.getScenarioID());
final String comment = sample.getComment();
if (sample.isSummary()) {
final boolean isGlobal = sample.isGlobal();
int commentId = 0;
final int commentKind = sample.getCommentType();
if ((commentKind == Performance.EXPLAINS_DEGRADATION_COMMENT) && (comment != null)) {
commentId = fSQL.getCommentId(commentKind, comment);
}
final Dimension[] summaryDimensions = sample.getSummaryDimensions();
for (final Dimension dimension : summaryDimensions) {
if (dimension instanceof Dim) {
fSQL.createSummaryEntry(variation_id, scenario_id, ((Dim) dimension).getId(), isGlobal, commentId);
}
}
final String shortName = sample.getShortname();
if (shortName != null) {
fSQL.setScenarioShortName(scenario_id, shortName);
}
} else if (comment != null) {
int commentId = 0;
final int commentKind = sample.getCommentType();
if (commentKind == Performance.EXPLAINS_DEGRADATION_COMMENT) {
commentId = fSQL.getCommentId(commentKind, comment);
}
// use
fSQL.createSummaryEntry(variation_id, scenario_id, 0, false, commentId);
// special
// dim
// id
// '0'
// to
// identify
// summary
// entry
// created
// to
// only
// handle
// a
// comment
}
final int sample_id = fSQL.createSample(variation_id, scenario_id, new Timestamp(sample.getStartTime()));
if (AGGREGATE) {
final StatisticsSession stats = new StatisticsSession(dataPoints);
final Dim[] dims = dataPoints[0].getDimensions();
int datapoint_id = fSQL.createDataPoint(sample_id, 0, InternalPerformanceMeter.AVERAGE);
for (final Dim dim : dims) {
fSQL.insertScalar(datapoint_id, dim.getId(), (long) stats.getAverage(dim));
}
datapoint_id = fSQL.createDataPoint(sample_id, 0, InternalPerformanceMeter.STDEV);
for (final Dim dim : dims) {
// see StatisticsSession
final long value = Double.doubleToLongBits(stats.getStddev(dim));
fSQL.insertScalar(datapoint_id, dim.getId(), value);
}
datapoint_id = fSQL.createDataPoint(sample_id, 0, InternalPerformanceMeter.SIZE);
for (final Dim dim : dims) {
fSQL.insertScalar(datapoint_id, dim.getId(), stats.getCount(dim));
}
} else {
for (int i = 0; i < dataPoints.length; i++) {
final DataPoint dp = dataPoints[i];
final int datapoint_id = fSQL.createDataPoint(sample_id, i, dp.getStep());
final Scalar[] scalars = dp.getScalars();
for (final Scalar scalar : scalars) {
final int dim_id = scalar.getDimension().getId();
final long value = scalar.getMagnitude();
fSQL.insertScalar(datapoint_id, dim_id, value);
}
}
}
fConnection.commit();
fStoredSamples++;
fStoreCalled = true;
// System.err.println(System.currentTimeMillis()-l);
} catch (final SQLException e) {
PerformanceTestPlugin.log(e);
try {
fConnection.rollback();
} catch (final SQLException e1) {
PerformanceTestPlugin.log(e1);
}
}
return true;
}
use of org.eclipse.test.internal.performance.eval.StatisticsSession in project eclipse.platform.releng by eclipse.
the class Scenario method loadSessions.
private void loadSessions() {
if (fSessions != null)
return;
loadSeriesNames();
long start;
Variations v = (Variations) fSharedState.fVariations.clone();
if (DEBUG)
start = System.currentTimeMillis();
ArrayList<StatisticsSession> sessions = new ArrayList<>();
ArrayList<String> names2 = new ArrayList<>();
Set<Dim> dims = new HashSet<>();
for (String fSeriesName : fSeriesNames) {
v.put(fSharedState.fSeriesKey, fSeriesName);
DataPoint[] dps = DB.queryDataPoints(v, fScenarioName, fSharedState.fQueryDimensions);
if (DEBUG)
// $NON-NLS-1$
System.err.println(" dps length: " + dps.length);
if (dps.length > 0) {
dims.addAll(dps[0].getDimensions2());
sessions.add(new StatisticsSession(dps));
names2.add(fSeriesName);
}
}
if (DEBUG)
// $NON-NLS-1$
System.err.println("data: " + (System.currentTimeMillis() - start));
fSessions = sessions.toArray(new StatisticsSession[sessions.size()]);
fSeriesNames = names2.toArray(new String[sessions.size()]);
fDimensions = dims.toArray(new Dim[dims.size()]);
Arrays.sort(fDimensions, (o1, o2) -> {
Dim d1 = o1;
Dim d2 = o2;
return d1.getName().compareTo(d2.getName());
});
}
use of org.eclipse.test.internal.performance.eval.StatisticsSession in project eclipse.platform.releng by eclipse.
the class InternalPerformanceMeter method printSample.
private void printSample(PrintStream ps, Sample sample) {
// $NON-NLS-1$ //$NON-NLS-2$
ps.print("Scenario '" + getScenarioName() + "' ");
DataPoint[] dataPoints = sample.getDataPoints();
if (dataPoints.length > 0) {
StatisticsSession s = new StatisticsSession(dataPoints);
Dim[] dimensions = dataPoints[0].getDimensions();
Arrays.sort(dimensions, new DimensionComparator());
if (dimensions.length > 0) {
List<Dim> badDimensions = new ArrayList<>();
long n = s.getCount(dimensions[0]);
// $NON-NLS-1$
MessageFormat format = new MessageFormat("({0,number,percent} in [{1}, {2}])");
// $NON-NLS-1$
String spaces = " ";
// $NON-NLS-1$ //$NON-NLS-2$
ps.println("(average over " + n + " samples):");
for (Dim dimension : dimensions) {
double mean = s.getAverage(dimension);
// $NON-NLS-1$ //$NON-NLS-2$
String nameString = " " + dimension.getName() + ":";
String meanString = dimension.getDisplayValue(mean);
int align = firstNonDigit(meanString);
int endIndex = 30 - align - nameString.length();
if (endIndex > 0)
meanString = spaces.substring(0, endIndex) + meanString;
align = nameString.length() + meanString.length();
Percentile percentile = StatisticsUtil.T95;
double[] confidenceInterval = s.getConfidenceInterval(dimension, percentile);
StringBuffer printBuffer;
if (n <= 2) {
// $NON-NLS-1$
printBuffer = new StringBuffer(" (no confidence)");
} else {
printBuffer = new StringBuffer();
int ns = align;
while (ns++ < 40) printBuffer.append(' ');
printBuffer.append(format.format(new Object[] { Double.valueOf(percentile.inside()), dimension.getDisplayValue(confidenceInterval[0]), dimension.getDisplayValue(confidenceInterval[1]) }));
}
align += printBuffer.length();
try {
while (align++ < 70) printBuffer.append(' ');
printBuffer.append(checkSampleSize(s, sample, dimension));
} catch (CoreException x) {
badDimensions.add(dimension);
continue;
}
ps.print(nameString);
ps.print(meanString);
ps.println(printBuffer);
}
if (!badDimensions.isEmpty()) {
// $NON-NLS-1$
ps.print(" Dimensions with unusable statistical properties: ");
for (Iterator<Dim> iter = badDimensions.iterator(); iter.hasNext(); ) {
Dim dimension = iter.next();
ps.print(dimension.getName());
if (iter.hasNext())
// $NON-NLS-1$
ps.print(", ");
}
ps.println();
}
}
}
ps.println();
}
Aggregations