public void sparsePrint(PrintStream stream) {
    if (mSeries.isEmpty()) {
      return;
    }
    long start = mSeries.firstKey();
    stream.printf("Time series starts at %d with width %d.%n", start, mWidthNano);

    for (Map.Entry<Long, Integer> entry : mSeries.entrySet()) {
      stream.printf("%d %d%n", (entry.getKey() - start) / mWidthNano, entry.getValue());
    }
  }
@Test
  public void sparsePrintTest() {
    TimeSeries timeSeries = new TimeSeries();
    timeSeries.record(mBase);
    timeSeries.record(mBase + 8L * Constants.SECOND_NANO);

    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    PrintStream printStream = new PrintStream(outputStream);
    timeSeries.sparsePrint(printStream);

    StringBuilder sb = new StringBuilder();
    sb.append(
        String.format("Time series starts at %d with width %d.%n", mBase, Constants.SECOND_NANO));
    sb.append(String.format("%d %d%n", 0, 1));
    sb.append(String.format("%d %d%n", 8, 1));

    Assert.assertEquals(sb.toString(), outputStream.toString());
  }