use of org.eclipse.test.internal.performance.data.Scalar 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.data.Scalar in project eclipse.platform.releng by eclipse.
the class DB method internalQueryDataPoints.
private DataPoint[] internalQueryDataPoints(final Variations variations, final String scenarioName, final Set<Dim> dimSet) {
if (fSQL == null) {
return null;
}
long start = System.currentTimeMillis();
if (DEBUG) {
// $NON-NLS-1$ //$NON-NLS-2$
System.out.print(" - query data points from DB for scenario " + scenarioName + "...");
}
final ArrayList<DataPoint> dataPoints = new ArrayList<>();
try (ResultSet rs = fSQL.queryDataPoints(variations, scenarioName)) {
if (DEBUG) {
final long time = System.currentTimeMillis();
// $NON-NLS-1$ //$NON-NLS-2$
System.out.println("done in " + (time - start) + "ms");
start = time;
}
while (rs.next()) {
final int datapoint_id = rs.getInt(1);
final int step = rs.getInt(2);
final HashMap<Dim, Scalar> map = new HashMap<>();
try (final ResultSet rs2 = fSQL.queryScalars(datapoint_id)) {
while (rs2.next()) {
final int dim_id = rs2.getInt(1);
final long value = rs2.getBigDecimal(2).longValue();
final Dim dim = Dim.getDimension(dim_id);
if (dim != null) {
if ((dimSet == null) || dimSet.contains(dim)) {
map.put(dim, new Scalar(dim, value));
}
}
}
if (map.size() > 0) {
dataPoints.add(new DataPoint(step, map));
}
}
}
final int n = dataPoints.size();
if (DEBUG) {
final long time = System.currentTimeMillis();
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
System.out.println(" + " + n + " datapoints created in " + (time - start) + "ms");
}
return dataPoints.toArray(new DataPoint[n]);
} catch (final SQLException e) {
PerformanceTestPlugin.log(e);
}
return null;
}
use of org.eclipse.test.internal.performance.data.Scalar in project eclipse.platform.releng by eclipse.
the class AbsoluteBandChecker method test.
@Override
public boolean test(StatisticsSession reference, StatisticsSession measured, StringBuffer message) {
Dim dimension = getDimension();
if (!measured.contains(dimension)) {
// $NON-NLS-1$
PerformanceTestPlugin.logWarning("collected data provides no dimension '" + dimension.getName() + '\'');
return true;
}
if (!reference.contains(dimension)) {
// $NON-NLS-1$
PerformanceTestPlugin.logWarning("reference data provides no dimension '" + dimension.getName() + '\'');
return true;
}
double actual = measured.getAverage(dimension);
double test = reference.getAverage(dimension);
if (actual > fUpperBand + test || actual < test - fLowerBand) {
message.append('\n' + dimension.getName() + ": " + dimension.getDisplayValue(actual) + " is not within [-" + dimension.getDisplayValue(new Scalar(null, fLowerBand)) + ", +" + dimension.getDisplayValue(new Scalar(null, fUpperBand)) + "] of " + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
dimension.getDisplayValue(test));
return false;
}
return true;
}
use of org.eclipse.test.internal.performance.data.Scalar in project eclipse.platform.releng by eclipse.
the class StatisticsSession method getDelta.
private Scalar getDelta(DataPoint before, DataPoint after, Dim dimension) {
Scalar one = before.getScalar(dimension);
// $NON-NLS-1$
Assert.assertTrue("reference has no value for dimension " + dimension, one != null);
Scalar two = after.getScalar(dimension);
// $NON-NLS-1$
Assert.assertTrue("reference has no value for dimension " + dimension, two != null);
return new Scalar(one.getDimension(), two.getMagnitude() - one.getMagnitude());
}
use of org.eclipse.test.internal.performance.data.Scalar in project eclipse.platform.releng by eclipse.
the class StatisticsSession method computeStatsFromAggregates.
private Statistics computeStatsFromAggregates(Dim dimension) {
Statistics stats = new Statistics();
long aggregateCount = 0;
double averageSum = 0;
long countSum = 0;
double stdevSum = 0;
// Set acquiredAggregates= new HashSet();
for (int i = 0; i < fDataPoints.length; i++) {
DataPoint point = fDataPoints[i];
Scalar scalar = point.getScalar(dimension);
if (scalar == null)
continue;
Integer aggregate = Integer.valueOf(point.getStep());
// allow for multiple measurements that were each stored with their own
// aggregate values
// Assert.assertTrue(acquiredAggregates.add(aggregate));
long magnitude = scalar.getMagnitude();
switch(aggregate.intValue()) {
case InternalPerformanceMeter.AVERAGE:
averageSum += magnitude;
aggregateCount++;
break;
case InternalPerformanceMeter.STDEV:
// see DB.internalStore
stdevSum += Double.longBitsToDouble(magnitude);
break;
case InternalPerformanceMeter.SIZE:
countSum += magnitude;
break;
default:
// $NON-NLS-1$
Assert.fail("only average, stdev and size are supported in aggregate mode");
break;
}
}
stats.average = averageSum / aggregateCount;
// XXX this does not work! have to treat multiple runs like normal measurement
stats.stddev = stdevSum / aggregateCount;
// data
stats.count = countSum;
stats.sum = Math.round(stats.count * stats.average);
return stats;
}
Aggregations