private boolean isDownloadQuickerThanLocalBuild(BuildRunner buildRunner, int commitsCountBetweenCompilation,
                                                  List<CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope> scopes) {
    SystemOpsStatistic systemOpsStatistic = JpsServerConnectionUtil.measureConnectionSpeed(myNettyClient);
    if (systemOpsStatistic == null) {
      LOG.info("Connection speed is too small to download caches");
      return false;
    }

    Pair<Long, Integer> buildTimeAndProjectModulesCount = estimateProjectBuildTime(buildRunner, scopes);
    int projectModulesCount;
    long approximateBuildTime;
    if (buildTimeAndProjectModulesCount != null) {
      approximateBuildTime = buildTimeAndProjectModulesCount.first;
      projectModulesCount = buildTimeAndProjectModulesCount.second;
    } else {
      LOG.info("Rebuild or unexpected behaviour at build time calculation. Local build will be executed");
      return false;
    }

    if (approximateBuildTime == 0 && commitsCountBetweenCompilation > COMMITS_COUNT_THRESHOLD) {
      LOG.info("Can't calculate approximate project build time, but there are " + commitsCountBetweenCompilation + " not compiled " +
               "commits and it seems that it will be faster to download caches.");
      return true;
    }
    if (approximateBuildTime == 0) {
      LOG.info("Can't calculate approximate project build time");
      return false;
    }
    long approximateDownloadTime = calculateApproximateDownloadTimeMs(systemOpsStatistic, projectModulesCount);
    if (approximateDownloadTime == 0) {
      LOG.info("Can't calculate approximate download time");
      return false;
    }
    return approximateDownloadTime < approximateBuildTime;
  }
private boolean isDownloadQuickerThanLocalBuild(BuildRunner buildRunner, int commitsCountBetweenCompilation,
                                                  List<CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope> scopes)