Add TPSWatcher #62
32
SpigotCore_10/src/de/steamwar/core/SpigotTPS_10.java
Normale Datei
@ -0,0 +1,32 @@
|
||||
/*
|
||||
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.core;
|
||||
|
||||
import net.minecraft.server.v1_10_R1.MinecraftServer;
|
||||
|
||||
public class SpigotTPS_10 {
|
||||
|
||||
private SpigotTPS_10(){}
|
||||
|
||||
static double[] getTps(){
|
||||
return MinecraftServer.getServer().recentTps;
|
||||
}
|
||||
|
||||
}
|
32
SpigotCore_12/src/de/steamwar/core/SpigotTPS_12.java
Normale Datei
@ -0,0 +1,32 @@
|
||||
/*
|
||||
Lixfel
hat
Licence fehlt Licence fehlt
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.core;
|
||||
|
||||
import net.minecraft.server.v1_12_R1.MinecraftServer;
|
||||
|
||||
public class SpigotTPS_12 {
|
||||
|
||||
private SpigotTPS_12(){}
|
||||
|
||||
static double[] getTps(){
|
||||
return MinecraftServer.getServer().recentTps;
|
||||
}
|
||||
|
||||
}
|
32
SpigotCore_14/src/de/steamwar/core/SpigotTPS_14.java
Normale Datei
@ -0,0 +1,32 @@
|
||||
/*
|
||||
Lixfel
hat
Licence fehlt Licence fehlt
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.core;
|
||||
|
||||
import net.minecraft.server.v1_14_R1.MinecraftServer;
|
||||
|
||||
public class SpigotTPS_14 {
|
||||
|
||||
private SpigotTPS_14(){}
|
||||
|
||||
static double[] getTps(){
|
||||
return MinecraftServer.getServer().recentTps;
|
||||
}
|
||||
|
||||
}
|
32
SpigotCore_15/src/de/steamwar/core/SpigotTPS_15.java
Normale Datei
@ -0,0 +1,32 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
Lixfel
hat
Licence fehlt Licence fehlt
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.core;
|
||||
|
||||
import net.minecraft.server.v1_15_R1.MinecraftServer;
|
||||
|
||||
public class SpigotTPS_15 {
|
||||
|
||||
private SpigotTPS_15(){}
|
||||
|
||||
static double[] getTps(){
|
||||
return MinecraftServer.getServer().recentTps;
|
||||
}
|
||||
|
||||
}
|
32
SpigotCore_8/src/de/steamwar/core/SpigotTPS_8.java
Normale Datei
@ -0,0 +1,32 @@
|
||||
/*
|
||||
Lixfel
hat
Licence fehlt Licence fehlt
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.core;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.MinecraftServer;
|
||||
|
||||
public class SpigotTPS_8 {
|
||||
|
||||
private SpigotTPS_8(){}
|
||||
|
||||
static double[] getTps(){
|
||||
return MinecraftServer.getServer().recentTps;
|
||||
}
|
||||
|
||||
}
|
32
SpigotCore_9/src/de/steamwar/core/SpigotTPS_9.java
Normale Datei
@ -0,0 +1,32 @@
|
||||
/*
|
||||
Lixfel
hat
Licence fehlt Licence fehlt
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.core;
|
||||
|
||||
import net.minecraft.server.v1_9_R2.MinecraftServer;
|
||||
|
||||
public class SpigotTPS_9 {
|
||||
|
||||
private SpigotTPS_9(){}
|
||||
|
||||
static double[] getTps(){
|
||||
return MinecraftServer.getServer().recentTps;
|
||||
}
|
||||
|
||||
}
|
@ -64,6 +64,7 @@ public class Core extends JavaPlugin{
|
||||
ErrorLogger.init();
|
||||
getServer().getMessenger().registerIncomingPluginChannel(this, "sw:bridge", new BungeeReceiver());
|
||||
getServer().getMessenger().registerOutgoingPluginChannel(this, "sw:bridge");
|
||||
TPSWatcher.init();
|
||||
|
||||
}
|
||||
|
||||
@ -75,11 +76,11 @@ public class Core extends JavaPlugin{
|
||||
public static Core getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static int getVersion(){
|
||||
return version;
|
||||
}
|
||||
|
||||
|
||||
private static void setInstance(Core instance) {
|
||||
Core.instance = instance;
|
||||
}
|
||||
|
134
SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java
Normale Datei
@ -0,0 +1,134 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.core;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class TPSWatcher {
|
||||
|
||||
private static final double tickDefault = 20.0;
|
||||
|
||||
private static TPSWatcher tps_OneSecond;
|
||||
private static TPSWatcher tps_TenSecond;
|
||||
Lixfel
hat
Da wir weder die statistische Abweichung messen noch die Werte irgendwo hier speichern, ist meiner Meinung nach jegliche Liste hier verkehrt. Es reicht, wenn sich der 10s-Durchschnitt alle 10s aktualisiert und der 1s-Durchschnitt sich sekündlich aktualisiert, da muss nicht jeder Tick da sein => Keine Listen nötig. Ich möchte eine Implementierung ohne jegliche Listen. Da wir weder die statistische Abweichung messen noch die Werte irgendwo hier speichern, ist meiner Meinung nach jegliche Liste hier verkehrt. Es reicht, wenn sich der 10s-Durchschnitt alle 10s aktualisiert und der 1s-Durchschnitt sich sekündlich aktualisiert, da muss nicht jeder Tick da sein => Keine Listen nötig. Ich möchte eine Implementierung ohne jegliche Listen.
YoyoNow
hat
Warum können wir nicht auch die 10s immer passend die letzten 10 Sekunden anzeigt und nicht nach 10 Sekunden dann mal wieder die letzten 10 Sekunden, dass finde ich auch nicht so sinnvoll. Ich überlege mal ob ich das anders machen kann Warum können wir nicht auch die 10s immer passend die letzten 10 Sekunden anzeigt und nicht nach 10 Sekunden dann mal wieder die letzten 10 Sekunden, dass finde ich auch nicht so sinnvoll. Ich überlege mal ob ich das anders machen kann
Lixfel
hat
Weil wir dann 10 Werte cachen müssen. Deshalb. Ist wesentlich aufwändiger und aufwändiger zu warten für einen wesentlich geringeren Vorteil Weil wir dann 10 Werte cachen müssen. Deshalb. Ist wesentlich aufwändiger und aufwändiger zu warten für einen wesentlich geringeren Vorteil
|
||||
|
||||
public static void init() {
|
||||
tps_OneSecond = new TPSWatcher(1000);
|
||||
tps_TenSecond = new TPSWatcher(10000);
|
||||
}
|
||||
|
||||
private long lastTime = System.currentTimeMillis();
|
||||
|
||||
private double tps = 20.0;
|
||||
|
||||
private TPSWatcher(long timeInterval) {
|
||||
Bukkit.getScheduler().runTaskTimer(Core.getInstance(), () -> {
|
||||
long tickTime = System.currentTimeMillis() - lastTime;
|
||||
lastTime = System.currentTimeMillis();
|
||||
|
||||
Lixfel
hat
Wann wird now < 0? Wann wird now < 0?
|
||||
double now = 0;
|
||||
if (tickTime != 0) {
|
||||
now = (timeInterval / (double) tickTime) * tickDefault;
|
||||
}
|
||||
if (now < 0) {
|
||||
now = 0;
|
||||
}
|
||||
tps = now;
|
||||
}, timeInterval / 50, timeInterval / 50);
|
||||
}
|
||||
|
||||
public enum TPSType {
|
||||
|
||||
// With own implementation
|
||||
ONE_SECOND,
|
||||
TEN_SECONDS,
|
||||
// With getting the values from Spigot itself
|
||||
ONE_MINUTE,
|
||||
Lixfel
hat
Ich hätte gernde die Funktionalität als Static-Funktionalität, da wir sowieso nie mehr als einen TPSWatcher benötigen werden und der Aufruf für den Erhalt von TPS Werten kürzer wird. Ich hätte gernde die Funktionalität als Static-Funktionalität, da wir sowieso nie mehr als einen TPSWatcher benötigen werden und der Aufruf für den Erhalt von TPS Werten kürzer wird.
|
||||
FIVE_MINUTES,
|
||||
TEN_MINUTES
|
||||
|
||||
Lixfel
hat
Das hier, nur das hier einfach alle 1s bzw. alle 10s ausführen, und du hast deine DurchschnittsTPS für die letzte 1s/10s. Das hier, nur das hier einfach alle 1s bzw. alle 10s ausführen, und du hast deine DurchschnittsTPS für die letzte 1s/10s.
YoyoNow
hat
Kann ich es einfach jede Sekunde machen, und dann 10 werte merken für 10 Sekunden? Das ganze könnte ich in einem fixen array speichern und auswerten Kann ich es einfach jede Sekunde machen, und dann 10 werte merken für 10 Sekunden? Das ganze könnte ich in einem fixen array speichern und auswerten
|
||||
}
|
||||
|
||||
public double getTPS() {
|
||||
return getTPS(TPSType.ONE_SECOND);
|
||||
}
|
||||
|
||||
public double getTPSUnlimited() {
|
||||
return getTPSUnlimited(TPSType.ONE_SECOND);
|
||||
}
|
||||
|
||||
public double getTPS(TPSType tpsType) {
|
||||
switch (tpsType) {
|
||||
case TEN_SECONDS:
|
||||
Lixfel
hat
30s erscheint mir unnötig. 30s erscheint mir unnötig.
YoyoNow
hat
Ok dann werde ich diesen Wert rausstreichen Ok dann werde ich diesen Wert rausstreichen
|
||||
return round(tps_TenSecond.tps);
|
||||
case ONE_MINUTE:
|
||||
return round(getSpigotTPS()[0]);
|
||||
case FIVE_MINUTES:
|
||||
return round(getSpigotTPS()[1]);
|
||||
case TEN_MINUTES:
|
||||
return round(getSpigotTPS()[2]);
|
||||
|
||||
default:
|
||||
return round(tps_OneSecond.tps);
|
||||
}
|
||||
Lixfel
hat
Ich würde gerne mit dieser Methode wenn dann ALLE verfügbaren TPS-Werte bekommen wollen, auch die von Spigot gemessenen. Ich würde gerne mit dieser Methode wenn dann ALLE verfügbaren TPS-Werte bekommen wollen, auch die von Spigot gemessenen.
YoyoNow
hat
Ok also willst du das dann als array oder liste? Ok also willst du das dann als array oder liste?
|
||||
}
|
||||
|
||||
public double getTPSUnlimited(TPSType tpsType) {
|
||||
switch (tpsType) {
|
||||
case TEN_SECONDS:
|
||||
return roundUnlimited(tps_TenSecond.tps);
|
||||
case ONE_MINUTE:
|
||||
return roundUnlimited(getSpigotTPS()[0]);
|
||||
case FIVE_MINUTES:
|
||||
return roundUnlimited(getSpigotTPS()[1]);
|
||||
case TEN_MINUTES:
|
||||
return roundUnlimited(getSpigotTPS()[2]);
|
||||
|
||||
Lixfel
hat
Bitte noch auf maximal 20 TPS limiten, das verwirrt ansonsten die Leute immer total Bitte noch auf maximal 20 TPS limiten, das verwirrt ansonsten die Leute immer total
|
||||
default:
|
||||
return roundUnlimited(tps_OneSecond.tps);
|
||||
}
|
||||
}
|
||||
|
||||
private double[] getSpigotTPS() {
|
||||
switch (Core.getVersion()) {
|
||||
case 8:
|
||||
return SpigotTPS_8.getTps();
|
||||
case 9:
|
||||
return SpigotTPS_9.getTps();
|
||||
case 10:
|
||||
return SpigotTPS_10.getTps();
|
||||
case 14:
|
||||
return SpigotTPS_14.getTps();
|
||||
case 15:
|
||||
return SpigotTPS_15.getTps();
|
||||
|
||||
default:
|
||||
return SpigotTPS_12.getTps();
|
||||
}
|
||||
}
|
||||
|
||||
private double round(double d) {
|
||||
return Math.max(Math.round(d * 10) / 10.0, 20.0);
|
||||
}
|
||||
|
||||
private double roundUnlimited(double d) {
|
||||
return Math.round(d * 10) / 10.0;
|
||||
}
|
||||
|
||||
}
|
Licence fehlt