code: private static long simulate(long bytesPerSecond, long latency, int bytes, long timeTaken, boolean roundUp) {
          if ( bytesPerSecond <= 0) { //< defensive code
              return 0;
          }
  
          // workout how much we should have waited to read this amount of bytes
          double d = ((double) bytes / bytesPerSecond) * 1000;
  
          long expectedTime = (long) (roundUp ? Math.ceil(d) : Math.floor(d)) + latency;
          long diff = expectedTime - timeTaken;       //< subtract the amount of time ALREADY taken to get those bytes
  
          if (diff > 0) {
              StreamManager.threadSleep(diff);
          }
          return diff;
      }
docs: to adjust the waiting time