use of com.djrapitops.plan.gathering.domain.TPS in project Plan by plan-player-analytics.
the class TPSMutator method lowTpsSpikeCount.
public int lowTpsSpikeCount(double threshold) {
boolean wasLow = false;
int spikeCount = 0;
for (TPS tpsObj : tpsData) {
double tps = tpsObj.getTicksPerSecond();
if (0 <= tps && tps < threshold) {
if (!wasLow) {
spikeCount++;
wasLow = true;
}
} else {
wasLow = false;
}
}
return spikeCount;
}
use of com.djrapitops.plan.gathering.domain.TPS in project Plan by plan-player-analytics.
the class TPSMutator method toArrays.
public List<Number[]> toArrays(LineGraph.GapStrategy gapStrategy) {
List<Number[]> arrays = new ArrayList<>();
Long lastX = null;
for (TPS tps : tpsData) {
long date = tps.getDate();
if (gapStrategy.fillGaps && lastX != null && date - lastX > gapStrategy.acceptableGapMs) {
addMissingPoints(arrays, lastX, date, gapStrategy);
}
lastX = date;
arrays.add(tps.toArray());
}
return arrays;
}
use of com.djrapitops.plan.gathering.domain.TPS in project Plan by plan-player-analytics.
the class TPSMutator method serverDownTime.
public long serverDownTime() {
long lastDate = -1;
long downTime = 0;
tpsData.sort(new TPSComparator());
for (TPS tps : tpsData) {
long date = tps.getDate();
if (lastDate == -1) {
lastDate = date;
continue;
}
long diff = date - lastDate;
if (diff > TimeUnit.MINUTES.toMillis(3L)) {
downTime += diff;
}
lastDate = date;
}
return downTime;
}
use of com.djrapitops.plan.gathering.domain.TPS in project Plan by plan-player-analytics.
the class ServerUptimeCalculator method tryToGetServerUptimeMillisFromDatabase.
private Optional<Long> tryToGetServerUptimeMillisFromDatabase(ServerUUID serverUUID) {
long dataGapThreshold = TimeUnit.MINUTES.toMillis(3);
Database database = dbSystem.getDatabase();
Optional<Long> latestDataDate = database.query(TPSQueries.fetchLatestTPSEntryForServer(serverUUID)).map(TPS::getDate);
Optional<Long> dataBlockStartDate = database.query(TPSQueries.fetchLatestServerStartTime(serverUUID, dataGapThreshold));
if (!latestDataDate.isPresent() || !dataBlockStartDate.isPresent()) {
return Optional.empty();
}
if (System.currentTimeMillis() - latestDataDate.get() > dataGapThreshold) {
return Optional.empty();
}
return Optional.of(System.currentTimeMillis() - dataBlockStartDate.get());
}
use of com.djrapitops.plan.gathering.domain.TPS in project Plan by plan-player-analytics.
the class TPSMutatorTest method filterWorksCorrectly.
@Test
void filterWorksCorrectly() {
long monthAgo = time - TimeAmount.MONTH.toMillis(1L);
List<TPS> filtered = new TPSMutator(testData).filterDataBetween(monthAgo, time).all();
for (TPS tps : filtered) {
long date = tps.getDate();
if (date < monthAgo) {
fail("Data from over month ago was present");
}
if (date > time) {
fail("Data from after 'time' was present");
}
}
}
Aggregations