public boolean shouldThrottle(long amountSoFar, long sendStartMs) {
        if (this.targetThroughput < 0) {
            // No throttling in this case
            return false;
        }

        float elapsedSec = (sendStartMs - startMs) / 1000.f;
        return elapsedSec > 0 && ((double) amountSoFar / elapsedSec) > this.targetThroughput;
    }
@param amountSoFar bytes produced so far if you want to throttle data throughput, or
                   messages produced so far if you want to throttle message throughput.
@param sendStartMs timestamp of the most recently sent message
@return <code>true</code> if throttling should happen
server-common/src/main/java/org/apache/kafka/server/util/ThroughputThrottler.java