diff --git a/Plan/src/main/java/com/djrapitops/plan/data/analysis/TPSPart.java b/Plan/src/main/java/com/djrapitops/plan/data/analysis/TPSPart.java index 00c47f1ad..6ff51f986 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/analysis/TPSPart.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/analysis/TPSPart.java @@ -19,7 +19,7 @@ import java.util.List; *

* Contains following place-holders: tpsscatterday, tpsscatterweek, cpuscatterday, cpuscatterweek, averagetps(-week), * averagetpsday, averagecpuday, averagecpuweek, averagememoryday, averagememoryweek, averageentitiesday, averageentitiesweek, - * averagechunksday, averagechunkweek + * averagechunksday, averagechunkweek, ramscatterday, ramscatterweek * * @author Rsl1122 * @since 3.5.2 @@ -42,6 +42,8 @@ public class TPSPart extends RawData { String tpsScatterWeek = TPSGraphCreator.buildScatterDataStringTPS(week, TimeAmount.WEEK.ms()); String cpuScatterDay = CPUGraphCreator.buildScatterDataString(day, TimeAmount.DAY.ms()); String cpuScatterWeek = CPUGraphCreator.buildScatterDataString(week, TimeAmount.WEEK.ms()); + String ramScatterDay = CPUGraphCreator.buildScatterDataString(day, TimeAmount.DAY.ms()); + String ramScatterWeek = CPUGraphCreator.buildScatterDataString(week, TimeAmount.WEEK.ms()); addValue("tpsscatterday", tpsScatterDay); addValue("tpsscatterweek", tpsScatterWeek); @@ -49,6 +51,12 @@ public class TPSPart extends RawData { addValue("cpuscatterday", cpuScatterDay); addValue("cpuscatterweek", cpuScatterWeek); + addValue("ramscatterday", ramScatterDay); + addValue("ramscatterweek", ramScatterWeek); + + Runtime runtime = Runtime.getRuntime(); + addValue("maxram", (runtime.maxMemory() / (1024L * 1024L))); + double averageTPSWeek = MathUtils.averageDouble(week.stream().map(TPS::getTps)); double averageTPSDay = MathUtils.averageDouble(day.stream().map(TPS::getTps)); diff --git a/Plan/src/main/java/com/djrapitops/plan/ui/html/graphs/RamGraphCreator.java b/Plan/src/main/java/com/djrapitops/plan/ui/html/graphs/RamGraphCreator.java index be6d9487b..4dcc540fc 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ui/html/graphs/RamGraphCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/ui/html/graphs/RamGraphCreator.java @@ -1,5 +1,19 @@ package main.java.com.djrapitops.plan.ui.html.graphs; +import main.java.com.djrapitops.plan.data.TPS; +import main.java.com.djrapitops.plan.utilities.MiscUtils; +import main.java.com.djrapitops.plan.utilities.analysis.Point; + +import java.util.List; +import java.util.stream.Collectors; + public class RamGraphCreator { - // TODO + public static String buildScatterDataString(List tpsData, long scale) { + long now = MiscUtils.getTime(); + List points = tpsData.stream() + .filter(tps -> tps.getDate() >= now - scale) + .map(tps -> new Point(tps.getDate(), tps.getUsedMemory())) + .collect(Collectors.toList()); + return ScatterGraphCreator.scatterGraph(points, true); + } } diff --git a/Plan/src/main/resources/analysis.html b/Plan/src/main/resources/analysis.html index a8b9df4ab..b60fbf39d 100644 --- a/Plan/src/main/resources/analysis.html +++ b/Plan/src/main/resources/analysis.html @@ -726,7 +726,7 @@

-

If CPU Graph displays '-1' CPU usage is not available for this platform.

+

If Graph displays '-1' usage is not available for this platform.

@@ -1395,6 +1395,7 @@ datasets: [ { label: "CPU Usage", + yAxisID: 'A', fill: false, lineTension: 0.1, borderColor: "#e0d264", @@ -1413,6 +1414,27 @@ pointHitRadius: 10, spanGaps: false, data: %cpuscatterday% + }, { + label: "Memory Usage", + yAxisID: 'B', + fill: false, + lineTension: 0.1, + borderColor: "#7dcc24", + borderCapStyle: 'butt', + borderDash: [], + borderDashOffset: 0.0, + borderJoinStyle: 'miter', + pointBorderColor: "#7dcc24", + pointBackgroundColor: "#7dcc24", + pointBorderWidth: 1, + pointHoverRadius: 5, + pointHoverBackgroundColor: "#7dcc24", + pointHoverBorderColor: "#8fabc6", + pointHoverBorderWidth: 2, + pointRadius: 1, + pointHitRadius: 10, + spanGaps: false, + data: %ramscatterday% }] }; var cpuChart = new Chart(ctxcpu, { @@ -1431,6 +1453,7 @@ }, scales: { yAxes: [{ + id: 'A', type: 'linear', position: 'left', ticks: { @@ -1439,9 +1462,21 @@ }, scaleLabel: { display: true, - labelString: 'CPU Usage' + labelString: 'CPU Usage (%)' } - }], + }, { + id: 'B', + type: 'linear', + position: 'right', + ticks: { + suggestedMax: %maxram%, + suggestedMin: 0 + }, + scaleLabel: { + display: true, + labelString: 'Memory Usage (Mt)' + } + }], xAxes: [{ type: 'linear', display: false @@ -1459,6 +1494,7 @@ datasets: [ { label: "CPU Usage", + yAxisID: 'A', fill: false, lineTension: 0.1, borderColor: "#e0d264", @@ -1477,6 +1513,27 @@ pointHitRadius: 10, spanGaps: false, data: %cpuscatterweek% + }, { + label: "Memory Usage", + yAxisID: 'B', + fill: false, + lineTension: 0.1, + borderColor: "#7dcc24", + borderCapStyle: 'butt', + borderDash: [], + borderDashOffset: 0.0, + borderJoinStyle: 'miter', + pointBorderColor: "#7dcc24", + pointBackgroundColor: "#7dcc24", + pointBorderWidth: 1, + pointHoverRadius: 5, + pointHoverBackgroundColor: "#7dcc24", + pointHoverBorderColor: "#8fabc6", + pointHoverBorderWidth: 2, + pointRadius: 1, + pointHitRadius: 10, + spanGaps: false, + data: %ramscatterday% }] }; var cpuChart = new Chart(ctxcpu, { @@ -1495,6 +1552,7 @@ }, scales: { yAxes: [{ + id: 'A', type: 'linear', position: 'left', ticks: { @@ -1503,7 +1561,19 @@ }, scaleLabel: { display: true, - labelString: 'CPU Usage' + labelString: 'CPU Usage (%)' + } + }, { + id: 'B', + type: 'linear', + position: 'right', + ticks: { + suggestedMax: %maxram%, + suggestedMin: 0 + }, + scaleLabel: { + display: true, + labelString: 'Memory Usage (Mt)' } }], xAxes: [{