public double getRateAndReset() {
        long currentTime = System.nanoTime();
        long deltaTime = currentTime - lastTime;
        if (deltaTime <= 0) {
            return 0;
        }

        long currentTraffic = trafficCounter.get();
        long deltaTraffic = currentTraffic - lastTraffic;

        lastTime = currentTime;
        lastTraffic = currentTraffic;

        return deltaTraffic * 1e9 / deltaTime;
    }
Calculate the rate of bytes transferred since the last call to this method, and reset the counter.
Note: This method is not thread-safe.
s3stream/src/main/java/com/automq/stream/s3/operator/TrafficMonitor.java