public static RTCStatList getPCStatOvertime(WebDriver webDriver, String peerConnection, int durationInMilliSeconds, int intervalInMilliSeconds, JsonArray selectedStats, int batchId, String platform)
    throws KiteTestException {
    RTCStatList statsOverTime = new RTCStatList();
    switch(platform.toLowerCase()){
      case "android":
      case "ios":
        int threadTime;
        for (int timer = 0; timer <= durationInMilliSeconds; timer += threadTime) {
          long start = System.currentTimeMillis();
          statsOverTime.add(getPCStatOnce(webDriver, peerConnection, selectedStats, batchId, platform));
          threadTime = (int) (System.currentTimeMillis() - start);
          if (threadTime < intervalInMilliSeconds) {
            waitAround(Math.abs((intervalInMilliSeconds - threadTime) - ONE_SECOND_INTERVAL));
            threadTime = intervalInMilliSeconds;
          }
        }
        break;
      default:
        for (int timer = 0; timer <= durationInMilliSeconds; timer += intervalInMilliSeconds) {
          statsOverTime.add(getPCStatOnce(webDriver, peerConnection, selectedStats, batchId, platform));
          if (timer <= durationInMilliSeconds - intervalInMilliSeconds) {
            waitAround(Math.abs(intervalInMilliSeconds - ONE_SECOND_INTERVAL));
          }
        }
        break;
    }

    return statsOverTime;
  }
stat JsonObjectBuilder to add to callback result.

@param webDriver              used to execute command.
@param peerConnection         the peer connection
@param durationInMilliSeconds during which the stats will be collected.
@param intervalInMilliSeconds between each time getStats gets called.
@param selectedStats          list of selected stats.

@return JsonObjectBuilder of the stat object
@throws KiteTestException the kite test exception
KITE-Framework/src/main/java/org/webrtc/kite/stats/StatsUtils.java