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