simulator/src/main/java/com/hazelcast/simulator/worker/performance/PerformanceStats.java
public void add(PerformanceStats other, boolean addOperationCountAndThroughput) {
        if (other.isEmpty()) {
            return;
        }

        if (isEmpty()) {
            operationCount = other.operationCount;
            intervalThroughput = other.intervalThroughput;
            totalThroughput = other.totalThroughput;

            intervalLatencyAvgNanos = other.intervalLatencyAvgNanos;
            intervalLatency999PercentileNanos = other.intervalLatency999PercentileNanos;
            intervalLatencyMaxNanos = other.intervalLatencyMaxNanos;
        } else {
            if (addOperationCountAndThroughput) {
                operationCount += other.operationCount;
                intervalThroughput += other.intervalThroughput;
                totalThroughput += other.totalThroughput;
            } else {
                operationCount = max(operationCount, other.operationCount);
                intervalThroughput = max(intervalThroughput, other.intervalThroughput);
                totalThroughput = max(totalThroughput, other.totalThroughput);
            }

            intervalLatencyAvgNanos = max(intervalLatencyAvgNanos, other.intervalLatencyAvgNanos);
            intervalLatency999PercentileNanos = max(intervalLatency999PercentileNanos, other.intervalLatency999PercentileNanos);
            intervalLatencyMaxNanos = max(intervalLatencyMaxNanos, other.intervalLatencyMaxNanos);
        }
    }
public void add(PerformanceStats other, boolean addOperationCountAndThroughput) {
        if (other.isEmpty()) {
            return;
        }

        if (isEmpty()) {
            operationCount = other.operationCount;
            intervalThroughput = other.intervalThroughput;
            totalThroughput = other.totalThroughput;

            intervalLatencyAvgNanos = other.intervalLatencyAvgNanos;
            intervalLatency999PercentileNanos = other.intervalLatency999PercentileNanos;
            intervalLatencyMaxNanos = other.intervalLatencyMaxNanos;
        } else {
            if (addOperationCountAndThroughput) {
                operationCount += other.operationCount;
                intervalThroughput += other.intervalThroughput;
                totalThroughput += other.totalThroughput;
            } else {
                operationCount = max(operationCount, other.operationCount);
                intervalThroughput = max(intervalThroughput, other.intervalThroughput);
                totalThroughput = max(totalThroughput, other.totalThroughput);
            }

            intervalLatencyAvgNanos = max(intervalLatencyAvgNanos, other.intervalLatencyAvgNanos);
            intervalLatency999PercentileNanos = max(intervalLatency999PercentileNanos, other.intervalLatency999PercentileNanos);
            intervalLatencyMaxNanos = max(intervalLatencyMaxNanos, other.intervalLatencyMaxNanos);
        }
    }
Combines {@link PerformanceStats} instances, e.g. from different Simulator Workers.
<p>
For the real-time performance monitor during the {@link TestPhase#RUN} the
maximum value should be set, so we get the maximum operation count and throughput values of all {@link PerformanceStats}
instances of the last interval.
<p>
For the total performance number and the performance per Simulator Agent, the added values should be set, so we get the
summed up operation count and throughput values.
<p>
The method always sets the maximum values for latency.

@param other                          {@link PerformanceStats} which should be added to this instance
@param addOperationCountAndThroughput {@code true} if operation count and throughput should be added,
{@code false} if the maximum value should be set