use of com.serotonin.log.LogStopWatch in project ma-core-public by infiniteautomation.
the class PointValueDaoMetrics method deleteOrphanedPointValuesWithoutCount.
/* (non-Javadoc)
* @see com.serotonin.m2m2.db.dao.PointValueDao#deleteOrphanedPointValuesWithoutCount()
*/
@Override
public void deleteOrphanedPointValuesWithoutCount() {
LogStopWatch LogStopWatch = new LogStopWatch();
dao.deleteOrphanedPointValuesWithoutCount();
LogStopWatch.stop("deleteOrphanedPointValuesWithoutCount()", this.metricsThreshold);
}
use of com.serotonin.log.LogStopWatch in project ma-core-public by infiniteautomation.
the class PointValueDaoMetrics method getLatestPointValues.
/*
* (non-Javadoc)
* @see com.serotonin.m2m2.db.dao.PointValueDao#getLatestPointValues(java.util.List, java.lang.Integer, long, boolean, com.infiniteautomation.mango.db.query.PVTQueryCallback)
*/
public void getLatestPointValues(List<Integer> ids, long before, boolean orderById, Integer limit, PVTQueryCallback<IdPointValueTime> callback) {
LogStopWatch LogStopWatch = new LogStopWatch();
dao.getLatestPointValues(ids, before, orderById, limit, callback);
LogStopWatch.stop("getLatestPointValues(pointId,limit,before, orderById, callback) (" + ids + ", " + limit + ", " + before + "," + orderById + ", callback)", this.metricsThreshold);
}
use of com.serotonin.log.LogStopWatch in project ma-core-public by infiniteautomation.
the class PointValueDaoMetrics method deleteOrphanedPointValues.
/* (non-Javadoc)
* @see com.serotonin.m2m2.db.dao.PointValueDao#deleteOrphanedPointValues()
*/
@Override
public long deleteOrphanedPointValues() {
LogStopWatch LogStopWatch = new LogStopWatch();
long value = dao.deleteOrphanedPointValues();
LogStopWatch.stop("deleteOrphanedPointValues()", this.metricsThreshold);
return value;
}
use of com.serotonin.log.LogStopWatch in project ma-core-public by infiniteautomation.
the class PointValueDaoMetrics method getLatestPointValues.
/* (non-Javadoc)
* @see com.serotonin.m2m2.db.dao.PointValueDao#getLatestPointValues(int, int)
*/
@Override
public List<PointValueTime> getLatestPointValues(int pointId, int limit) {
LogStopWatch LogStopWatch = new LogStopWatch();
List<PointValueTime> values = dao.getLatestPointValues(pointId, limit);
LogStopWatch.stop("getLatestPointValues(pointId,limit) (" + pointId + ", " + limit + "){" + values.size() + "}", this.metricsThreshold);
return values;
}
use of com.serotonin.log.LogStopWatch in project ma-modules-public by infiniteautomation.
the class MultiPointLatestDatabaseStream method simplify.
/**
* Simplify according to our requirements
*
* TODO This currently only works for Numeric Points
*
* @param list
* @return
*/
protected List<DataPointVOPointValueTimeBookend> simplify(List<DataPointVOPointValueTimeBookend> list) {
LogStopWatch logStopWatch = new LogStopWatch();
if (info.simplifyTolerance != null) {
// TODO improve Simplify code to return a list
Simplify<DataPointVOPointValueTimeBookend> simplify = new Simplify<DataPointVOPointValueTimeBookend>(new DataPointVOPointValueTimeBookend[0], SimplifyPointValueExtractor.extractor);
DataPointVOPointValueTimeBookend[] simplified = simplify.simplify(list.toArray(new DataPointVOPointValueTimeBookend[list.size()]), info.simplifyTolerance, info.simplifyHighQuality);
logStopWatch.stop("Finished Simplify, tolerance: " + info.simplifyTolerance);
return Arrays.asList(simplified);
} else {
if (list.size() < info.simplifyTarget)
return list;
// Compute target bounds as 10% of target
int lowerTarget = info.simplifyTarget - (int) (info.simplifyTarget * 0.1);
int upperTarget = info.simplifyTarget + (int) (info.simplifyTarget * 0.1);
// Compute tolerance bounds and initial tolerance
Double max = Double.MIN_VALUE;
Double min = Double.MAX_VALUE;
for (DataPointVOPointValueTimeBookend value : list) {
if (value.getPvt().getDoubleValue() > max)
max = value.getPvt().getDoubleValue();
if (value.getPvt().getDoubleValue() < min)
min = value.getPvt().getDoubleValue();
}
double difference = max - min;
double tolerance = difference / 20d;
double topBound = difference;
double bottomBound = 0;
// Determine max iterations we can allow
int maxIterations = 100;
int iteration = 1;
Simplify<DataPointVOPointValueTimeBookend> simplify = new Simplify<DataPointVOPointValueTimeBookend>(new DataPointVOPointValueTimeBookend[0], SimplifyPointValueExtractor.extractor);
DataPointVOPointValueTimeBookend[] simplified = simplify.simplify(list.toArray(new DataPointVOPointValueTimeBookend[list.size()]), tolerance, info.simplifyHighQuality);
DataPointVOPointValueTimeBookend[] best = simplified;
while (simplified.length < lowerTarget || simplified.length > upperTarget) {
if (simplified.length > info.simplifyTarget) {
bottomBound = tolerance;
} else {
topBound = tolerance;
}
// Adjust tolerance
tolerance = bottomBound + (topBound - bottomBound) / 2.0d;
simplify = new Simplify<DataPointVOPointValueTimeBookend>(new DataPointVOPointValueTimeBookend[0], SimplifyPointValueExtractor.extractor);
simplified = simplify.simplify(list.toArray(new DataPointVOPointValueTimeBookend[list.size()]), tolerance, info.simplifyHighQuality);
// Keep our best effort
if (Math.abs(info.simplifyTarget - simplified.length) < Math.abs(info.simplifyTarget - best.length))
best = simplified;
if (iteration > maxIterations) {
simplified = best;
break;
}
iteration++;
}
logStopWatch.stop("Finished Simplify, target: " + info.simplifyTarget + " actual " + simplified.length);
return Arrays.asList(simplified);
}
}
Aggregations