Skip to content

Commit

Permalink
Added /speedtest command and rule speedTestCommandMaxTestSize
Browse files Browse the repository at this point in the history
  • Loading branch information
Fallen-Breath committed Nov 19, 2023
1 parent c49bac2 commit ed1ee58
Show file tree
Hide file tree
Showing 39 changed files with 2,331 additions and 38 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {

// https://github.com/ReplayMod/preprocessor
// https://github.com/Fallen-Breath/preprocessor
id 'com.replaymod.preprocess' version '20c7ec554a'
id 'com.replaymod.preprocess' version 'ce1aeb2b'

// https://github.com/Fallen-Breath/yamlang
id 'me.fallenbreath.yamlang' version '1.3.1' apply false
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/carpettisaddition/CarpetTISAdditionServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import carpettisaddition.commands.removeentity.RemoveEntityCommand;
import carpettisaddition.commands.scounter.SupplierCounterCommand;
import carpettisaddition.commands.sleep.SleepCommand;
import carpettisaddition.commands.speedtest.SpeedTestCommand;
import carpettisaddition.commands.stop.StopCommandDoubleConfirmation;
import carpettisaddition.helpers.rule.instantBlockUpdaterReintroduced.InstantBlockUpdaterChanger;
import carpettisaddition.helpers.rule.lightEngineMaxBatchSize.LightBatchSizeChanger;
Expand Down Expand Up @@ -139,9 +140,10 @@ public void onServerLoaded(MinecraftServer server)
@Override
public void onServerClosed(MinecraftServer server)
{
RaidTracker.getInstance().stop();
MicroTimingLoggerManager.detachServer();
LifeTimeTracker.detachServer();
MicroTimingLoggerManager.detachServer();
RaidTracker.getInstance().stop();
SpeedTestCommand.getInstance().onServerClosed();
}

@Override
Expand Down Expand Up @@ -179,6 +181,7 @@ public void registerCommands(
RaycastCommand.getInstance(),
RemoveEntityCommand.getInstance(),
SleepCommand.getInstance(),
SpeedTestCommand.getInstance(),
SupplierCounterCommand.getInstance()
).forEach(command ->
command.registerCommand(context)
Expand All @@ -189,6 +192,7 @@ public void registerCommands(
public void onPlayerLoggedOut(ServerPlayerEntity player)
{
TISCMServerPacketHandler.getInstance().onPlayerDisconnected(player.networkHandler);
SpeedTestCommand.getInstance().onPlayerDisconnected(player);
}

//#if MC >= 11500
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/carpettisaddition/CarpetTISAdditionSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ public ValidateChunkUpdatePacketThreshold()
@Rule(categories = {TIS, COMMAND, CREATIVE})
public static String commandSleep = "ops";

@Rule(categories = {TIS, COMMAND, TISCM_PROTOCOL})
public static String commandSpeedTest = "false";

@Rule(categories = {TIS, CREATIVE})
public static boolean creativeNetherWaterPlacement = false;

Expand Down Expand Up @@ -518,6 +521,14 @@ public ValidateOakBalloonPercent()
)
public static int snowMeltMinLightLevel = VANILLA_SNOW_MELT_MIN_LIGHT_LEVEL;

@Rule(
options = {"10", "100", "1024", "10240"},
strict = false,
validators = Validators.PositiveNumber.class,
categories = {TIS, COMMAND}
)
public static int speedTestCommandMaxTestSize = 10;

@Rule(categories = {TIS, COMMAND})
public static boolean stopCommandDoubleConfirmation = false;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* This file is part of the Carpet TIS Addition project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2023 Fallen_Breath and contributors
*
* Carpet TIS Addition is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Carpet TIS Addition 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Carpet TIS Addition. If not, see <https://www.gnu.org/licenses/>.
*/

package carpettisaddition.commands.speedtest;

public class ProgressTimer
{
private long startTimeNs = 0;

public void start()
{
this.startTimeNs = System.nanoTime();
}

public long getStartTimeNs()
{
return this.startTimeNs;
}

public long getTimeElapsedNs()
{
return System.nanoTime() - this.startTimeNs;
}
}
Loading

0 comments on commit ed1ee58

Please sign in to comment.