diff --git a/src/main/java/ru/windcorp/progressia/test/LayerTestGUI.java b/src/main/java/ru/windcorp/progressia/test/LayerTestGUI.java index ca02ed8..ddf273f 100755 --- a/src/main/java/ru/windcorp/progressia/test/LayerTestGUI.java +++ b/src/main/java/ru/windcorp/progressia/test/LayerTestGUI.java @@ -260,13 +260,82 @@ public class LayerTestGUI extends GUILayer { } } + + private static class Counter { + + private int DISPLAY_INERTIA = 200; + private long AVERAGE_TIME = 10000; + private long first_time; + + private final long[] values; + private int size; + private int head; + + private long lastUpdate; + + public Counter(long averageTime, int maxTPS) + { + DISPLAY_INERTIA = (int) averageTime*maxTPS/1000; + AVERAGE_TIME = averageTime; + first_time = -1; + values = new long[DISPLAY_INERTIA]; + } + + public void add(long value) { + if (first_time==-1) + { + first_time=System.currentTimeMillis(); + } + if (size == values.length) { + values[head] = value; + head++; + if (head == values.length) + head = 0; + } else { + values[size] = value; + size++; + } + } + + public double average() { + double count=0; + long ctime = System.currentTimeMillis(); + for (int i=0;i TPS_STRING = DynamicStrings.builder() .addDyn(new MutableStringLocalized("LayerTestGUI.TPSDisplay")) - .addDyn(() -> TPS_RECORD.update(ServerState.getInstance().getTPS()), 5, 1) + .addDyn(() -> TPS_RECORD.update(), 5, 1) .buildSupplier(); private static final Supplier POS_STRING = DynamicStrings.builder()