code: @VisibleForTesting
    String countersToString() {
      StringBuilder sb = new StringBuilder();
      sb.append("\n");
      double numNanoSecPerSec = TimeUnit.SECONDS.toNanos(1);
      String timeSuffix = "_TIME";
      for (Counter c : Counter.values()) {
        String name = c.toString();
        if (!name.endsWith(timeSuffix)) {
          // Log invocation counter.
          long count = counters.get(c).get();
          sb.append(String.format("%20s = %d calls\n", name, count));
  
          // Log duration counter.
          String timeCounterName = name + timeSuffix;
          double totalTime =
              counters.get(Enum.valueOf(Counter.class, timeCounterName)).get()
                  / numNanoSecPerSec;
          sb.append(String.format("%20s = %.2f sec\n", timeCounterName, totalTime));
  
          // Compute and log average duration per call (== total duration / num invocations).
          String avgName = name + " avg.";
          double avg = totalTime / count;
          sb.append(String.format("%20s = %.2f sec / call\n\n", avgName, avg));
        }
      }
      return sb.toString();
    }
docs: Gets value of all counters as a formatted string.