@Override public FloatCounter read(Kryo kryo, Input input, Class<FloatCounter> type) { WindowedMean windowedMean = kryo.readObjectOrNull(input, WindowedMean.class); FloatCounter floatCounter = new FloatCounter(windowedMean == null ? 0 : windowedMean.getWindowSize()); if (windowedMean != null) { float[] windowedMeanValues = windowedMean.getWindowValues(); for (float f : windowedMeanValues) { // restores the private WindowedMean floatCounter.put(f); } } floatCounter.count = input.readInt(); floatCounter.total = input.readFloat(); floatCounter.min = input.readFloat(); floatCounter.max = input.readFloat(); floatCounter.average = input.readFloat(); floatCounter.latest = input.readFloat(); floatCounter.value = input.readFloat(); return floatCounter; }
@Override public FloatCounter copy (Kryo kryo, FloatCounter original) { WindowedMean windowedMean = original.mean; FloatCounter floatCounter = new FloatCounter(windowedMean == null ? 0 : windowedMean.getWindowSize()); if (windowedMean != null) { float[] windowedMeanValues = windowedMean.getWindowValues(); for (float f : windowedMeanValues) { // restores the private WindowedMean floatCounter.put(f); } } floatCounter.count = original.count; floatCounter.total = original.total; floatCounter.min = original.min; floatCounter.max = original.max; floatCounter.average = original.average; floatCounter.latest = original.latest; floatCounter.value = original.value; return floatCounter; }
@Override public void write(Kryo kryo, Output output, FloatCounter floatCounter) { kryo.writeObjectOrNull(output, floatCounter.mean, WindowedMean.class); output.writeInt(floatCounter.count); output.writeFloat(floatCounter.total); output.writeFloat(floatCounter.min); output.writeFloat(floatCounter.max); output.writeFloat(floatCounter.average); output.writeFloat(floatCounter.latest); output.writeFloat(floatCounter.value); }
private static String toString(FloatCounter counter) { StringBuilder sb = new StringBuilder(); sb.append("{count = " + counter.count); sb.append(", total = " + counter.total); sb.append(", min = " + counter.min); sb.append(", max = " + counter.max); sb.append(", average = " + counter.average); sb.append(", value = " + counter.value); sb.append("}"); return sb.toString(); }
public PerformanceCounter (final String name, final int windowSize) { this.name = name; this.time = new FloatCounter(windowSize); this.load = new FloatCounter(1); }
public AISearchAgent( TranspositionTable transpositionTable, HistoryTable historyTable, BoardEvaluator<U> evaluator, RulesChecker rulesChecker, int depth) { this.transTable = transpositionTable; this.historyTable = historyTable; this.evaluator = evaluator; this.rulesChecker = rulesChecker; this.depth = depth; this.random = new Random(); depthCounters = new Array<FloatCounter>(); for (int i = 0; i < depth; i++) { depthCounters.add(new FloatCounter(0){ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{count = " + count); sb.append(", total = " + total); sb.append(", min = " + min); sb.append(", max = " + max); sb.append(", average = " + average); sb.append(", value = " + value); sb.append("}"); return sb.toString(); } }); } this.arrayPool = new Pool<Array<Move>>(){ @Override protected Array<Move> newObject() { return new Array<Move>(); } @Override public void free (Array<Move> object) { object.size = 0; super.free(object); } }; }
public PerformanceCounter(final String name, final int windowSize) { this.name = name; this.time = new FloatCounter(windowSize); this.load = new FloatCounter(1); }