private void renderSlowHistory(PerformanceLogWriter writer) {
   writer.startSection("SlowHistory");
   for (String item : slowOccurrences.descendingKeys()) {
     writer.writeEntry(item + " samples=" + slowOccurrences.get(item));
   }
   writer.endSection();
 }
  private void runCurrent(PerformanceLogWriter writer, long now) {
    writer.startSection("Pending");
    for (Invocation invocation : invocationRegistry) {
      long durationMs = now - invocation.firstInvocationTimeMillis;
      if (durationMs >= thresholdMillis) {
        writer.writeEntry(invocation.toString() + " duration=" + durationMs + " ms");
        slowOccurrences.add(invocation.op.getClass().getName(), 1);
      }

      occurrences.add(invocation.op.getClass().getName(), 1);
    }
    writer.endSection();
  }
  @Override
  public void run(PerformanceLogWriter writer) {
    long now = Clock.currentTimeMillis();

    writer.startSection("Invocations");

    runCurrent(writer, now);

    renderHistory(writer);

    renderSlowHistory(writer);

    writer.endSection();
  }