void () { myFreezeDetector.stop(); if (LOG.isDebugEnabled()) { LOG.debug("update expected build time for " + myTotalBuildTimeForFullyRebuiltTargets.size() + " target types"); } myTotalBuildTimeForFullyRebuiltTargets.object2LongEntrySet().fastForEach(entry -> { BuildTargetType<?> type = entry.getKey(); long totalTime = entry.getLongValue(); BuildTargetsState targetsState = myDataManager.getTargetsState(); long oldAverageTime = targetsState.getAverageBuildTime(type); long newAverageTime; if (oldAverageTime == -1) { newAverageTime = totalTime / myNumberOfFullyRebuiltTargets.getInt(type); } else { //if not all targets of this type were fully rebuilt, we assume that old average value is still actual for them; this way we won't get incorrect value if only one small target was fully rebuilt newAverageTime = (totalTime + (myTotalTargets.getInt(type) - myNumberOfFullyRebuiltTargets.getInt(type)) * oldAverageTime) / myTotalTargets.getInt(type); } if (LOG.isDebugEnabled()) { LOG.debug(" " + type.getTypeId() + ": old=" + oldAverageTime + ", new=" + newAverageTime + " (based on " + myNumberOfFullyRebuiltTargets.getInt(type) + " of " + myTotalTargets.getInt(type) + " targets)"); } targetsState.setAverageBuildTime(type, newAverageTime); }); }