mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-01 07:25:51 +00:00
fix benchmarking not disabling properly
This commit is contained in:
parent
a56cd4c268
commit
5705caa1ba
@ -66,8 +66,10 @@ public class IrisPregenerator {
|
||||
private final KSet<Position2> net;
|
||||
private final ChronoLatch cl;
|
||||
private final ChronoLatch saveLatch = new ChronoLatch(30000);
|
||||
private final IrisPackBenchmarking benchmarking;
|
||||
|
||||
public IrisPregenerator(PregenTask task, PregeneratorMethod generator, PregenListener listener) {
|
||||
benchmarking = IrisPackBenchmarking.getInstance();
|
||||
this.listener = listenify(listener);
|
||||
cl = new ChronoLatch(5000);
|
||||
generatedRegions = new KSet<>();
|
||||
@ -135,7 +137,7 @@ public class IrisPregenerator {
|
||||
double percentage = ((double) generated.get() / (double) totalChunks.get()) * 100;
|
||||
|
||||
Iris.info("%s: %s of %s (%.0f%%), %s/s ETA: %s",
|
||||
IrisPackBenchmarking.benchmarkInProgress ? "Benchmarking" : "Pregen",
|
||||
benchmarking != null ? "Benchmarking" : "Pregen",
|
||||
Form.f(generated.get()),
|
||||
Form.f(totalChunks.get()),
|
||||
percentage,
|
||||
@ -174,10 +176,10 @@ public class IrisPregenerator {
|
||||
task.iterateRegions((x, z) -> visitRegion(x, z, false));
|
||||
Iris.info("Pregen took " + Form.duration((long) p.getMilliseconds()));
|
||||
shutdown();
|
||||
if (!IrisPackBenchmarking.benchmarkInProgress) {
|
||||
if (benchmarking == null) {
|
||||
Iris.info(C.IRIS + "Pregen stopped.");
|
||||
} else {
|
||||
IrisPackBenchmarking.instance.finishedBenchmark(chunksPerSecondHistory);
|
||||
benchmarking.finishedBenchmark(chunksPerSecondHistory);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,6 @@ import com.volmit.iris.util.format.Form;
|
||||
import com.volmit.iris.util.io.IO;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
@ -24,28 +23,28 @@ import java.util.Collections;
|
||||
|
||||
|
||||
public class IrisPackBenchmarking {
|
||||
@Getter
|
||||
public static IrisPackBenchmarking instance;
|
||||
public static boolean benchmarkInProgress = false;
|
||||
private static final ThreadLocal<IrisPackBenchmarking> instance = new ThreadLocal<>();
|
||||
private final PrecisionStopwatch stopwatch = new PrecisionStopwatch();
|
||||
private final IrisDimension dimension;
|
||||
private final int radius;
|
||||
private final boolean gui;
|
||||
|
||||
public IrisPackBenchmarking(IrisDimension dimension, int radius, boolean gui) {
|
||||
instance = this;
|
||||
this.dimension = dimension;
|
||||
this.radius = radius;
|
||||
this.gui = gui;
|
||||
runBenchmark();
|
||||
}
|
||||
|
||||
public static IrisPackBenchmarking getInstance() {
|
||||
return instance.get();
|
||||
}
|
||||
|
||||
private void runBenchmark() {
|
||||
Thread.ofVirtual()
|
||||
.name("PackBenchmarking")
|
||||
.start(() -> {
|
||||
Iris.info("Setting up benchmark environment ");
|
||||
benchmarkInProgress = true;
|
||||
IO.delete(new File(Bukkit.getWorldContainer(), "benchmark"));
|
||||
createBenchmark();
|
||||
while (!IrisToolbelt.isIrisWorld(Bukkit.getWorld("benchmark"))) {
|
||||
@ -59,10 +58,6 @@ public class IrisPackBenchmarking {
|
||||
|
||||
}
|
||||
|
||||
public boolean getBenchmarkInProgress() {
|
||||
return benchmarkInProgress;
|
||||
}
|
||||
|
||||
public void finishedBenchmark(KList<Integer> cps) {
|
||||
try {
|
||||
String time = Form.duration((long) stopwatch.getMilliseconds());
|
||||
@ -132,13 +127,18 @@ public class IrisPackBenchmarking {
|
||||
}
|
||||
|
||||
private void startBenchmark() {
|
||||
IrisToolbelt.pregenerate(PregenTask
|
||||
.builder()
|
||||
.gui(gui)
|
||||
.radiusX(radius)
|
||||
.radiusZ(radius)
|
||||
.build(), Bukkit.getWorld("benchmark")
|
||||
);
|
||||
try {
|
||||
instance.set(this);
|
||||
IrisToolbelt.pregenerate(PregenTask
|
||||
.builder()
|
||||
.gui(gui)
|
||||
.radiusX(radius)
|
||||
.radiusZ(radius)
|
||||
.build(), Bukkit.getWorld("benchmark")
|
||||
);
|
||||
} finally {
|
||||
instance.remove();
|
||||
}
|
||||
}
|
||||
|
||||
private double calculateAverage(KList<Integer> list) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user