Class AbstractStreamDecoderTest
java.lang.Object
org.apache.maven.surefire.api.stream.AbstractStreamDecoderTest
The performance of "get( Integer )" is 13.5 nano seconds on i5/2.6GHz:
The performance of getting event type by Segment is 33.7 nano seconds:
The performance of decoder:
The performance of decoding 100 bytes via CharacterDecoder - 71 nano seconds:
The performance of a pure string creation (instead of decoder) - 31.5 nano seconds:
The performance of CharsetDecoder with empty ByteBuffer:
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
static void
setup()
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
-
Constructor Details
-
AbstractStreamDecoderTest
public AbstractStreamDecoderTest()
-
-
Method Details
-
setup
public static void setup() -
shouldDecodeHappyCase
- Throws:
Exception
-
shouldDecodeShifted
- Throws:
Exception
-
shouldNotDecode
- Throws:
Exception
-
shouldReadInt
- Throws:
Exception
-
shouldReadInteger
- Throws:
Exception
-
shouldReadNullInteger
- Throws:
Exception
-
shouldNotReadString
- Throws:
Exception
-
shouldReadString
- Throws:
Exception
-
shouldReadStringShiftedBuffer
- Throws:
Exception
-
shouldReadStringShiftedInput
- Throws:
Exception
-
shouldReadMultipleStringsAndShiftedInput
- Throws:
Exception
-
shouldDecode3BytesEncodedSymbol
- Throws:
Exception
-
shouldDecode100Bytes
- Throws:
Exception
-
shouldReadEventType
- Throws:
Exception
-
shouldEventTypeReachedEndOfStream
- Throws:
Exception
-
shouldEventTypeReachedMalformedHeader
- Throws:
Exception
-
shouldReadEmptyString
- Throws:
Exception
-
shouldReadNullString
- Throws:
Exception
-
shouldReadSingleCharString
- Throws:
Exception
-
shouldReadThreeCharactersString
- Throws:
Exception
-
shouldReadDefaultCharset
- Throws:
Exception
-
shouldReadNonDefaultCharset
- Throws:
Exception
-
shouldSetNonDefaultCharset
public void shouldSetNonDefaultCharset() -
malformedCharset
- Throws:
Exception
-