RAM Graph

This commit is contained in:
Rsl1122 2017-07-27 19:51:26 +03:00
parent 882fe3dad3
commit 435dbc17fc
3 changed files with 98 additions and 6 deletions

View File

@ -19,7 +19,7 @@ import java.util.List;
* <p>
* 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<TPSPart> {
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<TPSPart> {
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));

View File

@ -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<TPS> tpsData, long scale) {
long now = MiscUtils.getTime();
List<Point> 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);
}
}

View File

@ -726,7 +726,7 @@
</div>
<div class="box column">
<canvas id="cpu24h" width="1000" height="600" style="width: 95%;"></canvas>
<p>If CPU Graph displays '-1' CPU usage is not available for this platform.</p>
<p>If Graph displays '-1' usage is not available for this platform.</p>
</div>
</div>
</div>
@ -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: [{