public static void validateSettingsHistograms()

in agdk/util/tuningfork/tools/validation/src/main/java/com/google/tuningfork/validation/ValidationUtil.java [97:137]


  public static void validateSettingsHistograms(Settings settings, ErrorCollector errors) {
    final float FRAME_TIME_60FPS_MS = 16.7f;
    final float FRAME_TIME_30FPS_MS = 33.3f;
    List<Settings.Histogram> histograms = settings.getHistogramsList();
    for (Settings.Histogram histogram: histograms) {
      if (histogram.getBucketMin() == 0 && histogram.getBucketMax() == 0) {
        continue;
      }
      if (histogram.getNBuckets() < 1) {
        errors.addWarning(ErrorType.HISTOGRAM_BUCKET_INVALID,
                "Set n_Buckets to a positive integer. It is currently "
                        + histogram.getNBuckets());
      }
      boolean cover60fps = histogram.getBucketMin() < FRAME_TIME_60FPS_MS
              && histogram.getBucketMax() > FRAME_TIME_60FPS_MS;
      boolean cover30fps = histogram.getBucketMax() > FRAME_TIME_30FPS_MS
              && histogram.getBucketMin() < FRAME_TIME_30FPS_MS;
      if (histogram.hasBucketMax() && histogram.getBucketMax() < histogram.getBucketMin()) {
        errors.addWarning(ErrorType.HISTOGRAM_BUCKET_INVALID,
                "Bucket_Min has to be less than Bucket_Max. Max currently is "
                        + histogram.getBucketMax()
                        + "Min currently is " + histogram.getBucketMin());
      }

      if (histogram.getBucketMin() < 0.0f || histogram.getBucketMax() < 0.0f) {
        errors.addWarning(ErrorType.HISTOGRAM_BUCKET_INVALID,
                "Bucket_Min or Bucket_Max covers negative fps");
      }
      if (!cover30fps && !cover60fps) {
        errors.addWarning(ErrorType.HISTOGRAM_BUCKET_INVALID,
                "Histogram does not cover neither 30 nor 60 fps. It covers from "
                +  1000 / histogram.getBucketMax() + " to "
                        + 1000 / histogram.getBucketMin() + " fps");
      }
      if (cover30fps ^ cover60fps) {
        int num = cover30fps ? 30 : 60;
        errors.addWarning(ErrorType.HISTOGRAM_BUCKET_INVALID,
                "Histogram covers only " + num + " fps");
      }
    }
  }