maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [maven-surefire] Tibor17 commented on a change in pull request #310: 300 - 400 nanos per decoding std-out (100 chars/line)
Date Sat, 12 Sep 2020 20:47:35 GMT

Tibor17 commented on a change in pull request #310:
URL: https://github.com/apache/maven-surefire/pull/310#discussion_r487395060



##########
File path: maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/extensions/EventConsumerThreadTest.java
##########
@@ -0,0 +1,492 @@
+package org.apache.maven.plugin.surefire.extensions;
+
+import org.apache.maven.plugin.surefire.extensions.EventConsumerThread.Memento;
+import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
+import org.apache.maven.surefire.api.booter.ForkedProcessEventType;
+import org.apache.maven.surefire.extensions.EventHandler;
+import org.apache.maven.surefire.extensions.ForkNodeArguments;
+import org.apache.maven.surefire.extensions.util.CountdownCloseable;
+import org.fest.assertions.Assertions;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
+import org.mockito.Mockito;
+
+import javax.annotation.Nonnull;
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.channels.Channel;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CoderResult;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.concurrent.TimeUnit;
+
+import static java.nio.charset.CodingErrorAction.REPLACE;
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.maven.plugin.surefire.extensions.EventConsumerThreadTest.StreamReadStatus.EOF;
+import static org.apache.maven.plugin.surefire.extensions.EventConsumerThreadTest.StreamReadStatus.OVERFLOW;
+import static org.apache.maven.plugin.surefire.extensions.EventConsumerThreadTest.StreamReadStatus.UNDERFLOW;
+import static org.apache.maven.surefire.api.booter.Constants.STREAM_ENCODING;
+import static org.fest.assertions.Assertions.assertThat;
+//import static org.mockito.Mockito.mock;
+
+//@RunWith( Parameterized.class )
+public class EventConsumerThreadTest
+{
+    @Parameters
+    public static Iterable<Object> channels()
+    {
+        return Arrays.asList( (Object) complexEncodings() );
+    }
+
+    @Parameter
+    public Channel channel;
+
+    private static Channel complexEncodings()
+    {
+        byte[] bytes = new byte[]{(byte) -30, (byte) -126, (byte) -84, 'a', 'b', (byte) 0xc2,
(byte) 0xa9, 'c'};
+        bytes = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789".getBytes(
UTF_8 );
+        return new Channel( bytes, 1 );
+    }
+
+    private static Channel complexEncodings( int chunkSize )
+    {
+        byte[] bytes = new byte[]{(byte) -30, (byte) -126, (byte) -84, 'a', 'b', (byte) 0xc2,
(byte) 0xa9, 'c'};
+        bytes = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789".getBytes(
UTF_8 );
+        return new Channel( bytes, chunkSize );
+    }
+
+    @Test
+    public void test5() throws IOException, InterruptedException
+    {
+        /*final CharsetDecoder decoder = STREAM_ENCODING.newDecoder()

Review comment:
       ah no, these tests yet contain performance tests. Now they don't have a value for us
and they can be deleted.
   Yet only `EventConsumerThread` can be reviewed.
   
   Initially i used the tests to measure several approaches for decoding byte[] to String,
e.g. `new String()` vs CharacterBuffer, strings concatenation, decoding with/out number-of-bytes
in the stream `:2:AB:`, i had to measure time of objects creation, measured the exec time
of HashMap and hashcode/equals methods - see the class `Segment`  and measured the performance
of binary data tree against hashcode/equals. So initially these tests were used for selecting
the right approach means performance/code-approach.

##########
File path: maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/extensions/EventConsumerThreadTest.java
##########
@@ -0,0 +1,492 @@
+package org.apache.maven.plugin.surefire.extensions;
+
+import org.apache.maven.plugin.surefire.extensions.EventConsumerThread.Memento;
+import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
+import org.apache.maven.surefire.api.booter.ForkedProcessEventType;
+import org.apache.maven.surefire.extensions.EventHandler;
+import org.apache.maven.surefire.extensions.ForkNodeArguments;
+import org.apache.maven.surefire.extensions.util.CountdownCloseable;
+import org.fest.assertions.Assertions;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
+import org.mockito.Mockito;
+
+import javax.annotation.Nonnull;
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.channels.Channel;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CoderResult;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.concurrent.TimeUnit;
+
+import static java.nio.charset.CodingErrorAction.REPLACE;
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.maven.plugin.surefire.extensions.EventConsumerThreadTest.StreamReadStatus.EOF;
+import static org.apache.maven.plugin.surefire.extensions.EventConsumerThreadTest.StreamReadStatus.OVERFLOW;
+import static org.apache.maven.plugin.surefire.extensions.EventConsumerThreadTest.StreamReadStatus.UNDERFLOW;
+import static org.apache.maven.surefire.api.booter.Constants.STREAM_ENCODING;
+import static org.fest.assertions.Assertions.assertThat;
+//import static org.mockito.Mockito.mock;
+
+//@RunWith( Parameterized.class )
+public class EventConsumerThreadTest
+{
+    @Parameters
+    public static Iterable<Object> channels()
+    {
+        return Arrays.asList( (Object) complexEncodings() );
+    }
+
+    @Parameter
+    public Channel channel;
+
+    private static Channel complexEncodings()
+    {
+        byte[] bytes = new byte[]{(byte) -30, (byte) -126, (byte) -84, 'a', 'b', (byte) 0xc2,
(byte) 0xa9, 'c'};
+        bytes = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789".getBytes(
UTF_8 );
+        return new Channel( bytes, 1 );
+    }
+
+    private static Channel complexEncodings( int chunkSize )
+    {
+        byte[] bytes = new byte[]{(byte) -30, (byte) -126, (byte) -84, 'a', 'b', (byte) 0xc2,
(byte) 0xa9, 'c'};
+        bytes = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789".getBytes(
UTF_8 );
+        return new Channel( bytes, chunkSize );
+    }
+
+    @Test
+    public void test5() throws IOException, InterruptedException
+    {
+        /*final CharsetDecoder decoder = STREAM_ENCODING.newDecoder()

Review comment:
       ah no, these tests yet contain performance tests. Now they don't have a value for us
and they can be deleted.
   Yet only `EventConsumerThread` can be reviewed.
   
   Initially i used the tests to measure several approaches for decoding byte[] to String,
e.g. `new String()` vs CharacterBuffer, strings concatenation, decoding with/out number-of-bytes
in the stream `:2:AB:`, i had to measure time of objects creation, measured the exec time
of HashMap and hashcode/equals methods - see the class `Segment`  and measured the performance
of binary data tree against hashcode/equals. So initially these tests were used for selecting
the right approach means performance/code-approach.

##########
File path: maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/extensions/EventConsumerThreadTest.java
##########
@@ -0,0 +1,492 @@
+package org.apache.maven.plugin.surefire.extensions;
+
+import org.apache.maven.plugin.surefire.extensions.EventConsumerThread.Memento;
+import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
+import org.apache.maven.surefire.api.booter.ForkedProcessEventType;
+import org.apache.maven.surefire.extensions.EventHandler;
+import org.apache.maven.surefire.extensions.ForkNodeArguments;
+import org.apache.maven.surefire.extensions.util.CountdownCloseable;
+import org.fest.assertions.Assertions;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
+import org.mockito.Mockito;
+
+import javax.annotation.Nonnull;
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.channels.Channel;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CoderResult;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.concurrent.TimeUnit;
+
+import static java.nio.charset.CodingErrorAction.REPLACE;
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.maven.plugin.surefire.extensions.EventConsumerThreadTest.StreamReadStatus.EOF;
+import static org.apache.maven.plugin.surefire.extensions.EventConsumerThreadTest.StreamReadStatus.OVERFLOW;
+import static org.apache.maven.plugin.surefire.extensions.EventConsumerThreadTest.StreamReadStatus.UNDERFLOW;
+import static org.apache.maven.surefire.api.booter.Constants.STREAM_ENCODING;
+import static org.fest.assertions.Assertions.assertThat;
+//import static org.mockito.Mockito.mock;
+
+//@RunWith( Parameterized.class )
+public class EventConsumerThreadTest
+{
+    @Parameters
+    public static Iterable<Object> channels()
+    {
+        return Arrays.asList( (Object) complexEncodings() );
+    }
+
+    @Parameter
+    public Channel channel;
+
+    private static Channel complexEncodings()
+    {
+        byte[] bytes = new byte[]{(byte) -30, (byte) -126, (byte) -84, 'a', 'b', (byte) 0xc2,
(byte) 0xa9, 'c'};
+        bytes = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789".getBytes(
UTF_8 );
+        return new Channel( bytes, 1 );
+    }
+
+    private static Channel complexEncodings( int chunkSize )
+    {
+        byte[] bytes = new byte[]{(byte) -30, (byte) -126, (byte) -84, 'a', 'b', (byte) 0xc2,
(byte) 0xa9, 'c'};
+        bytes = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789".getBytes(
UTF_8 );
+        return new Channel( bytes, chunkSize );
+    }
+
+    @Test
+    public void test5() throws IOException, InterruptedException
+    {
+        /*final CharsetDecoder decoder = STREAM_ENCODING.newDecoder()

Review comment:
       ah no, these tests yet contain performance tests. Now they don't have a value for us
and they can be deleted.
   Yet only `EventConsumerThread` can be reviewed.
   
   Initially i used the tests to measure several approaches for decoding byte[] to String,
e.g. `new String()` vs CharacterBuffer, strings concatenation, decoding with/out number-of-bytes
in the stream `:2:AB:`, i had to measure time of objects creation, measured the exec time
of HashMap and hashcode/equals methods - see the class `Segment`  and measured the performance
of binary data tree against hashcode/equals. So initially these tests were used for selecting
the right approach means performance/code-approach.

##########
File path: maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/extensions/EventConsumerThreadTest.java
##########
@@ -0,0 +1,492 @@
+package org.apache.maven.plugin.surefire.extensions;
+
+import org.apache.maven.plugin.surefire.extensions.EventConsumerThread.Memento;
+import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
+import org.apache.maven.surefire.api.booter.ForkedProcessEventType;
+import org.apache.maven.surefire.extensions.EventHandler;
+import org.apache.maven.surefire.extensions.ForkNodeArguments;
+import org.apache.maven.surefire.extensions.util.CountdownCloseable;
+import org.fest.assertions.Assertions;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
+import org.mockito.Mockito;
+
+import javax.annotation.Nonnull;
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.channels.Channel;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CoderResult;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.concurrent.TimeUnit;
+
+import static java.nio.charset.CodingErrorAction.REPLACE;
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.maven.plugin.surefire.extensions.EventConsumerThreadTest.StreamReadStatus.EOF;
+import static org.apache.maven.plugin.surefire.extensions.EventConsumerThreadTest.StreamReadStatus.OVERFLOW;
+import static org.apache.maven.plugin.surefire.extensions.EventConsumerThreadTest.StreamReadStatus.UNDERFLOW;
+import static org.apache.maven.surefire.api.booter.Constants.STREAM_ENCODING;
+import static org.fest.assertions.Assertions.assertThat;
+//import static org.mockito.Mockito.mock;
+
+//@RunWith( Parameterized.class )
+public class EventConsumerThreadTest
+{
+    @Parameters
+    public static Iterable<Object> channels()
+    {
+        return Arrays.asList( (Object) complexEncodings() );
+    }
+
+    @Parameter
+    public Channel channel;
+
+    private static Channel complexEncodings()
+    {
+        byte[] bytes = new byte[]{(byte) -30, (byte) -126, (byte) -84, 'a', 'b', (byte) 0xc2,
(byte) 0xa9, 'c'};
+        bytes = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789".getBytes(
UTF_8 );
+        return new Channel( bytes, 1 );
+    }
+
+    private static Channel complexEncodings( int chunkSize )
+    {
+        byte[] bytes = new byte[]{(byte) -30, (byte) -126, (byte) -84, 'a', 'b', (byte) 0xc2,
(byte) 0xa9, 'c'};
+        bytes = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789".getBytes(
UTF_8 );
+        return new Channel( bytes, chunkSize );
+    }
+
+    @Test
+    public void test5() throws IOException, InterruptedException
+    {
+        /*final CharsetDecoder decoder = STREAM_ENCODING.newDecoder()

Review comment:
       ah no, these tests yet contain performance tests. Now they don't have a value for us
and they can be deleted.
   Yet only `EventConsumerThread` can be reviewed.
   
   Initially i used the tests to measure several approaches for decoding byte[] to String,
e.g. `new String()` vs CharacterBuffer, strings concatenation, decoding with/out number-of-bytes
in the stream `:2:AB:`, i had to measure time of objects creation, measured the exec time
of HashMap and hashcode/equals methods - see the class `Segment`  and measured the performance
of binary data tree against hashcode/equals. So initially these tests were used for selecting
the right approach means performance/code-approach.

##########
File path: maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/extensions/EventConsumerThreadTest.java
##########
@@ -0,0 +1,492 @@
+package org.apache.maven.plugin.surefire.extensions;
+
+import org.apache.maven.plugin.surefire.extensions.EventConsumerThread.Memento;
+import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
+import org.apache.maven.surefire.api.booter.ForkedProcessEventType;
+import org.apache.maven.surefire.extensions.EventHandler;
+import org.apache.maven.surefire.extensions.ForkNodeArguments;
+import org.apache.maven.surefire.extensions.util.CountdownCloseable;
+import org.fest.assertions.Assertions;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
+import org.mockito.Mockito;
+
+import javax.annotation.Nonnull;
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.channels.Channel;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CoderResult;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.concurrent.TimeUnit;
+
+import static java.nio.charset.CodingErrorAction.REPLACE;
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.maven.plugin.surefire.extensions.EventConsumerThreadTest.StreamReadStatus.EOF;
+import static org.apache.maven.plugin.surefire.extensions.EventConsumerThreadTest.StreamReadStatus.OVERFLOW;
+import static org.apache.maven.plugin.surefire.extensions.EventConsumerThreadTest.StreamReadStatus.UNDERFLOW;
+import static org.apache.maven.surefire.api.booter.Constants.STREAM_ENCODING;
+import static org.fest.assertions.Assertions.assertThat;
+//import static org.mockito.Mockito.mock;
+
+//@RunWith( Parameterized.class )
+public class EventConsumerThreadTest
+{
+    @Parameters
+    public static Iterable<Object> channels()
+    {
+        return Arrays.asList( (Object) complexEncodings() );
+    }
+
+    @Parameter
+    public Channel channel;
+
+    private static Channel complexEncodings()
+    {
+        byte[] bytes = new byte[]{(byte) -30, (byte) -126, (byte) -84, 'a', 'b', (byte) 0xc2,
(byte) 0xa9, 'c'};
+        bytes = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789".getBytes(
UTF_8 );
+        return new Channel( bytes, 1 );
+    }
+
+    private static Channel complexEncodings( int chunkSize )
+    {
+        byte[] bytes = new byte[]{(byte) -30, (byte) -126, (byte) -84, 'a', 'b', (byte) 0xc2,
(byte) 0xa9, 'c'};
+        bytes = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789".getBytes(
UTF_8 );
+        return new Channel( bytes, chunkSize );
+    }
+
+    @Test
+    public void test5() throws IOException, InterruptedException
+    {
+        /*final CharsetDecoder decoder = STREAM_ENCODING.newDecoder()

Review comment:
       ah no, these tests yet contain performance tests. Now they don't have a value for us
and they can be deleted.
   Yet only `EventConsumerThread` can be reviewed.
   
   Initially i used the tests to measure several approaches for decoding byte[] to String,
e.g. `new String()` vs CharacterBuffer, strings concatenation, decoding with/out number-of-bytes
in the stream `:2:AB:`, i had to measure time of objects creation, measured the exec time
of HashMap and hashcode/equals methods - see the class `Segment`  and measured the performance
of binary data tree against hashcode/equals. So initially these tests were used for selecting
the right approach means performance/code-approach.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



Mime
View raw message