public void testIntSignalCompressingConverter3() {
    final IntSignal intSignal = new IntSignal();
    final Random random = new Random();
    final long time = System.currentTimeMillis();
    for (int i = 0; i < 10000; i++) {
      intSignal.occur(time + i, (int) (Math.abs(random.nextGaussian()) * 3 + 1));
    }

    final IntSignal2BufferConverter plain = new IntSignal2BufferConverter();
    final Buffer plainBuffer = plain.convertTo(intSignal);

    final IntSignal2BufferCompressingConverter converter =
        new IntSignal2BufferCompressingConverter();
    final Buffer compressedBuffer = converter.convertTo(intSignal);

    final IntSignal2BufferCompressingConverter2 converter2 =
        new IntSignal2BufferCompressingConverter2();
    final Buffer compressedBuffer2 = converter2.convertTo(intSignal);

    System.out.println(
        "Compression ratio 1: "
            + ((double) plainBuffer.remaining()) / compressedBuffer.remaining());
    System.out.println(
        "Compression ratio 2: "
            + ((double) plainBuffer.remaining()) / compressedBuffer2.remaining());
  }
 public void testIntSignalConverter() {
   final IntSignal intSignal =
       new IntSignal(new long[] {1, 2, 3, 4, 5}, new int[] {2, 3, 4, 5, 6});
   final IntSignal2BufferConverter converter = new IntSignal2BufferConverter();
   final Buffer buffer = converter.convertTo(intSignal);
   IntSignal converted = converter.convertFrom(buffer);
   assertTrue(Arrays.equals(intSignal.getTimestamps(), converted.getTimestamps()));
   assertTrue(Arrays.equals(intSignal.getNativeValues(), converted.getNativeValues()));
 }
  public void testIntSignalCompressingConverterPerformance() {
    final IntSignal intSignal = new IntSignal();
    final Random random = new Random();
    final long time = System.currentTimeMillis();
    for (int i = 0; i < 10000; i++) {
      intSignal.occur(time + i, (int) (Math.abs(random.nextGaussian()) * 3 + 1));
    }

    final IntSignal2BufferConverter plain = new IntSignal2BufferConverter();
    final IntSignal2BufferCompressingConverter converter =
        new IntSignal2BufferCompressingConverter();
    final IntSignal2BufferCompressingConverter2 converter2 =
        new IntSignal2BufferCompressingConverter2();

    final int cnt = 500;
    Interval.start();
    for (int i = 0; i < cnt; i++) {
      final Buffer plainBuffer = plain.convertTo(intSignal);
      plain.convertFrom(plainBuffer);
    }
    Interval.stopAndPrint();

    Interval.start();
    for (int i = 0; i < cnt; i++) {
      final Buffer plainBuffer = converter.convertTo(intSignal);
      converter.convertFrom(plainBuffer);
    }
    Interval.stopAndPrint();

    Interval.start();
    for (int i = 0; i < cnt; i++) {
      final Buffer plainBuffer = converter2.convertTo(intSignal);
      converter2.convertFrom(plainBuffer);
    }
    Interval.stopAndPrint();
  }