String stats()

in simulator/src/main/java/com/google/cloud/StatsTracker.java [170:204]


    String stats(boolean reset) {

      // Fetch relevant stats as quckly as possible -- but synchronized
      long windowOps, windowBytes;
      double duration;
      List<Long> latencies;
      synchronized(this) {
        if (this.ops == 0) {
          return "N/A";
        }

        duration = (System.currentTimeMillis() - this.startTime)/1000.0;
        latencies = this.timings.getPercentile(buckets);
        windowOps = ops;
        windowBytes = bytes;

        if (reset) {
          startTime = System.currentTimeMillis();
          ops = 0;
          bytes = 0;
          timings.clear();
        }
      }

      // Format output
      return String.format("%s: %s %s %s %s %s %s %s",
          name,
          getFormattedBytes(windowBytes / duration),
          getFormattedOps(windowOps / duration),
          getFormattedLatency(latencies.get(0)),
          getFormattedLatency(latencies.get(1)),
          getFormattedLatency(latencies.get(2)),
          getFormattedLatency(latencies.get(3)),
          getFormattedLatency(latencies.get(4)));
    }