void report()

in Extremem/src/main/java/com/amazon/corretto/benchmark/extremem/RelativeTimeMetrics.java [1613:1869]


  void report(ExtrememThread t, boolean reportCSV) {

    String s;
    int l;

    if (total_entries == 0) {
      Report.output("Total measurements: 0");
      Report.output("  no further information available");
      return;
    }

    long median = 0;
    if (biu == 1) {
      // Very rough approximation
      median = lis + sis / 2;
    } else {
      // Calculate median assuming each logged data value
      // represents the middle of its respective range
      int entries_to_median = total_entries / 2;
      int index = fbi;
      for (int i = 0; i < biu; i++) {
        int bucket_count = buckets[index];
        long entry_value;
        
        if (sis > startAt(index))
          entry_value = (sis + (startAt(index) + spanAt(index))) / 2;
        else if (lis < startAt(index) + spanAt(index))
          // This test handles the case that lis is spanned by other than
          // last bucket in use.
          entry_value = (startAt(index) + lis) / 2;
        else
          entry_value = startAt(index) + spanAt(index) / 2;

        entries_to_median -= bucket_count;
        if (entries_to_median <= 0) {
          median = entry_value;
          break;
        }
        index = incrIndex(index);
      }
    }

    long average = accumulated_microseconds / total_entries;
    if (Trace.enabled(1))
      Report.output("                  Table: ", id);
    // otherwise, reporting the table id has little relevance

    if (reportCSV)
      Report.output("Total Measurement,Min,Max,Mean,Approximate Median");

    s = Integer.toString(total_entries);
    l = s.length();
    Util.ephemeralString(t, l);
    if (reportCSV)
      Report.outputNoLine(s, ",");
    else
      Report.output("     Total measurements: ", s);
    Util.abandonEphemeralString(t, l);
      
    if (reportCSV) {
      s = Long.toString(sis);
      l = s.length();
      Util.ephemeralString(t, l);
      Report.outputNoLine(s, ",");
    } else {
      s = us2s(t, sis);
      l = s.length();
      Report.output("           ranging from: ", s);
    }
    Util.abandonEphemeralString(t, l);
      
    if (reportCSV) {
      s = Long.toString(lis);
      l = s.length();
      Util.ephemeralString(t, l);
      Report.outputNoLine(s, ",");
    } else {
      s = us2s(t, lis);
      l = s.length();
      Report.output("                     to: ", s);
    }
    Util.abandonEphemeralString(t, l);
      
    if (reportCSV) {
      s = Long.toString(average);
      l = s.length();
      Util.ephemeralString(t, l);
      Report.outputNoLine(s, ",");
    } else {
      s = us2s(t, average);
      l = s.length();
      Report.output("        average latency: ", s);
    }
    Util.abandonEphemeralString(t, l);

    if (reportCSV) {
      s = Long.toString(median);
      l = s.length();
      Util.ephemeralString(t, l);
      Report.output(s);
    } else {
      s = us2s(t, median);
      l = s.length();
      Report.output("(approx) median latency: ", s);
    }
    Util.abandonEphemeralString(t, l);

    if (reportCSV) {
      s = Integer.toString(biu);
      Util.ephemeralString(t, s.length());
      Report.output("Buckets in use,", s);
      Util.abandonEphemeralString(t, s.length());
      
      Report.output("Bucket Start,Bucket End, Bucket Tally");
      int index = fbi;
      for (int i = 0; i < biu; i++) {
        String s1 = Long.toString(startAt(index));
        String s2 = Long.toString(startAt(index) + spanAt(index));
        String s3 = Integer.toString(buckets[index]);

        Util.ephemeralString(t, s1.length());
        Util.ephemeralString(t, s2.length());
        Util.ephemeralString(t, s3.length());

        Report.output(s1, ",", s2, ",", s3);

        Util.abandonEphemeralString(t, s1.length());
        Util.abandonEphemeralString(t, s2.length());
        Util.abandonEphemeralString(t, s3.length());

        index++;
        if (index >= BucketCount)
          index = 0;
      }
    } else {

      // Make a histogram with 64 equal-sized buckets
      long histo_columns[] = new long[HistoColumnCount];

      Trace.msg(4, id, ":Preparing histogram with ",
                Integer.toString(total_entries), " entries");
      Trace.msg(4, id, ":           ranging from: ", debug_us2s(sis));
      Trace.msg(4, id, ":                     to: ", debug_us2s(lis));
      Trace.msg(4, id, ":            from (fblb): ", debug_us2s(fblb));
      Trace.msg(4, id, ":              to (lbhb): ", debug_us2s(lbhb));

      long repack_lb = truncate256(sis);

      long repack_bucket_span = repackSpan(repack_lb, lis);
      repack(histo_columns, repack_lb, repack_bucket_span);
      int max_histo_size = 0;
      for (int i = 0; i < HistoColumnCount; i++) {
        if (histo_columns[i] > max_histo_size)
          max_histo_size = (int) histo_columns[i];
      }
      int num_rows = 0;
      int two_to_rows = 1;
      while (two_to_rows < max_histo_size) {
        num_rows++;
        two_to_rows += two_to_rows;
      }
      Report.output();
      Report.output("Logarithmic histogram (each column encoded as binary representation of tally total)");
      Report.output();
      Report.outputNoLine("        [");
      int avail_space = 62;

      s = us2decimal_ms(t, repack_lb);
      l = s.length();
      Report.outputNoLine(s);
      avail_space -= l;

      s = us2decimal_ms(t, repack_lb + HistoColumnCount * repack_bucket_span);
      l = s.length();
      avail_space -= l;
      while (avail_space-- > 0)
        Report.outputNoLine(" ");
      Report.outputNoLine(s);
      Report.output("]");

      // all values initially empty
      boolean[] populations = new boolean[HistoColumnCount];
      int last_populated_column = -1;

      // all values of seen_star initially false
      boolean[] seen_star = new boolean[HistoColumnCount];
      while (num_rows >= 0) {
        String histo_count = Integer.toString(two_to_rows);
        int pad = 7 - histo_count.length();
        for (int i = 0; i < pad; i++)
          Report.outputNoLine(" ");
        Report.outputNoLine(histo_count);
        Report.outputNoLine(" ");
        for (int col = 0; col < HistoColumnCount; col++) {
          if (two_to_rows <= histo_columns[col]) {
            Report.outputNoLine("1");
            populations[col] = true;
            if (last_populated_column < col)
              last_populated_column = col;
            histo_columns[col] -= two_to_rows;
          }
          else if (populations[col])
            Report.outputNoLine("0");
          else
            Report.outputNoLine(" ");
        }
        Report.output();
        two_to_rows /= 2;
        num_rows--;
      }
      Report.outputNoLine("        ");
      Report.output(
        "----------------------------------------------------------------");
      Report.outputNoLine("        ");
      int penultimate_column = -1;
      for (int i = 0; i <= last_populated_column; i++) {
        if (populations[i])
          Report.outputNoLine("^");
        else
          Report.outputNoLine(" ");
      }
      Report.output();

      boolean non_empty_column = (last_populated_column >= 0);
      while (last_populated_column > 0) {
        int penultimate_populated = -1;
        Report.outputNoLine("        ");
        for (int i = 0; i < last_populated_column; i++) {
          if (populations[i]) {
            Report.outputNoLine("|");
            penultimate_populated = i;
          } else
            Report.outputNoLine(" ");
        }
        Report.outputNoLine("+- < ");
        long span_end = repack_lb + (last_populated_column + 1) * repack_bucket_span;
        s = us2decimal_ms(t, span_end);
        Report.output(s);
        Util.abandonEphemeralString(t, s);
        last_populated_column = penultimate_populated;
      }
      if (non_empty_column) {
        Report.outputNoLine("        ");
        for (int i = 0; i < HistoColumnCount; i++) {
          if (populations[i]) {
            Report.outputNoLine("+- < ");
            long span_end = repack_lb + (i + 1) * repack_bucket_span;
            s = us2decimal_ms(t, span_end);
            Report.output(s);
            Util.abandonEphemeralString(t, s);
            break;
          } else
            Report.outputNoLine(" ");
        }
      }
    }
  }