Class AbstractStreamDecoderTest

java.lang.Object
org.apache.maven.surefire.api.stream.AbstractStreamDecoderTest

public class AbstractStreamDecoderTest extends Object
The performance of "get( Integer )" is 13.5 nano seconds on i5/2.6GHz:
     
     TreeMap<Integer, ForkedProcessEventType> map = new TreeMap<>();
     map.get( hash );
     
 

The performance of getting event type by Segment is 33.7 nano seconds:
     
     Map<Segment, ForkedProcessEventType> map = new HashMap<>();
     byte[] array = ForkedProcessEventType.BOOTERCODE_STDOUT.getOpcode().getBytes( UTF_8 );
     map.get( new Segment( array, 0, array.length ) );
     
 

The performance of decoder:
     
     CharsetDecoder decoder = STREAM_ENCODING.newDecoder()
             .onMalformedInput( REPLACE )
             .onUnmappableCharacter( REPLACE );
     ByteBuffer buffer = ByteBuffer.wrap( ForkedProcessEventType.BOOTERCODE_STDOUT.getOpcode().getBytes( UTF_8 ) );
     CharBuffer chars = CharBuffer.allocate( 100 );
     decoder.reset().decode( buffer, chars, true );

     String s = chars.flip().toString(); // 37 nanos = CharsetDecoder + toString

     buffer.clear();
     chars.clear();

     ForkedProcessEventType.byOpcode( s ); // 65 nanos = CharsetDecoder + toString + byOpcode
     
 

The performance of decoding 100 bytes via CharacterDecoder - 71 nano seconds:
     
     decoder.reset()
         .decode( buffer, chars, true ); // CharsetDecoder 71 nanos
     chars.flip().toString(); // CharsetDecoder + toString = 91 nanos
     
 

The performance of a pure string creation (instead of decoder) - 31.5 nano seconds:
     
     byte[] b = {};
     new String( b, UTF_8 );
     
 

The performance of CharsetDecoder with empty ByteBuffer:
     
     CharsetDecoder + ByteBuffer.allocate( 0 ) makes 11.5 nanos
     CharsetDecoder + ByteBuffer.allocate( 0 ) + toString() makes 16.1 nanos
     
 
  • Constructor Details

    • AbstractStreamDecoderTest

      public AbstractStreamDecoderTest()
  • Method Details

    • setup

      public static void setup()
    • shouldDecodeHappyCase

      public void shouldDecodeHappyCase() throws Exception
      Throws:
      Exception
    • shouldDecodeShifted

      public void shouldDecodeShifted() throws Exception
      Throws:
      Exception
    • shouldNotDecode

      public void shouldNotDecode() throws Exception
      Throws:
      Exception
    • shouldReadInt

      public void shouldReadInt() throws Exception
      Throws:
      Exception
    • shouldReadInteger

      public void shouldReadInteger() throws Exception
      Throws:
      Exception
    • shouldReadNullInteger

      public void shouldReadNullInteger() throws Exception
      Throws:
      Exception
    • shouldNotReadString

      public void shouldNotReadString() throws Exception
      Throws:
      Exception
    • shouldReadString

      public void shouldReadString() throws Exception
      Throws:
      Exception
    • shouldReadStringShiftedBuffer

      public void shouldReadStringShiftedBuffer() throws Exception
      Throws:
      Exception
    • shouldReadStringShiftedInput

      public void shouldReadStringShiftedInput() throws Exception
      Throws:
      Exception
    • shouldReadMultipleStringsAndShiftedInput

      public void shouldReadMultipleStringsAndShiftedInput() throws Exception
      Throws:
      Exception
    • shouldDecode3BytesEncodedSymbol

      public void shouldDecode3BytesEncodedSymbol() throws Exception
      Throws:
      Exception
    • shouldDecode100Bytes

      public void shouldDecode100Bytes() throws Exception
      Throws:
      Exception
    • shouldReadEventType

      public void shouldReadEventType() throws Exception
      Throws:
      Exception
    • shouldEventTypeReachedEndOfStream

      public void shouldEventTypeReachedEndOfStream() throws Exception
      Throws:
      Exception
    • shouldEventTypeReachedMalformedHeader

      public void shouldEventTypeReachedMalformedHeader() throws Exception
      Throws:
      Exception
    • shouldReadEmptyString

      public void shouldReadEmptyString() throws Exception
      Throws:
      Exception
    • shouldReadNullString

      public void shouldReadNullString() throws Exception
      Throws:
      Exception
    • shouldReadSingleCharString

      public void shouldReadSingleCharString() throws Exception
      Throws:
      Exception
    • shouldReadThreeCharactersString

      public void shouldReadThreeCharactersString() throws Exception
      Throws:
      Exception
    • shouldReadDefaultCharset

      public void shouldReadDefaultCharset() throws Exception
      Throws:
      Exception
    • shouldReadNonDefaultCharset

      public void shouldReadNonDefaultCharset() throws Exception
      Throws:
      Exception
    • shouldSetNonDefaultCharset

      public void shouldSetNonDefaultCharset()
    • malformedCharset

      public void malformedCharset() throws Exception
      Throws:
      Exception