You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2020/03/24 00:03:30 UTC

[maven-surefire] branch maven2surefire-jvm-communication updated (85f8c1f -> c914551)

This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a change to branch maven2surefire-jvm-communication
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git.


    from 85f8c1f  fixed the IT 735
     new f4bb445  improved performance from 320s to 54s.
     new c914551  investigated tests

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../surefire/extensions/EventConsumerThread.java   | 26 +++++++++++++++++-----
 .../surefire/extensions/SurefireForkChannel.java   |  4 +---
 .../src/test/java/consoleOutput/Test1.java         | 14 ++++++++++++
 .../src/test/java/consoleoutput_noisy/Test1.java   |  2 ++
 4 files changed, 37 insertions(+), 9 deletions(-)


[maven-surefire] 02/02: investigated tests

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch maven2surefire-jvm-communication
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit c914551d1ed9660a8e3c16bd589b95e8fe6755df
Author: tibordigana <ti...@apache.org>
AuthorDate: Sun Mar 22 22:20:58 2020 +0100

    investigated tests
---
 .../consoleOutput/src/test/java/consoleOutput/Test1.java   | 14 ++++++++++++++
 .../src/test/java/consoleoutput_noisy/Test1.java           |  2 ++
 2 files changed, 16 insertions(+)

diff --git a/surefire-its/src/test/resources/consoleOutput/src/test/java/consoleOutput/Test1.java b/surefire-its/src/test/resources/consoleOutput/src/test/java/consoleOutput/Test1.java
index 8994251..93e6a83 100644
--- a/surefire-its/src/test/resources/consoleOutput/src/test/java/consoleOutput/Test1.java
+++ b/surefire-its/src/test/resources/consoleOutput/src/test/java/consoleOutput/Test1.java
@@ -22,6 +22,8 @@ package consoleOutput;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.junit.Before;
+import org.junit.After;
 
 import static org.junit.Assert.fail;
 
@@ -50,6 +52,18 @@ public class Test1
        System.out.println("In constructor");
     }
 
+    @Before
+    public void t1()
+    {
+        System.out.println( "t1 = " + System.currentTimeMillis() );
+    }
+
+    @After
+    public void t2()
+    {
+        System.out.println( "t2 = " + System.currentTimeMillis() );
+    }
+
     @Test
     public void testStdOut()
     {
diff --git a/surefire-its/src/test/resources/consoleoutput-noisy/src/test/java/consoleoutput_noisy/Test1.java b/surefire-its/src/test/resources/consoleoutput-noisy/src/test/java/consoleoutput_noisy/Test1.java
index 888cd22..c7e562e 100644
--- a/surefire-its/src/test/resources/consoleoutput-noisy/src/test/java/consoleoutput_noisy/Test1.java
+++ b/surefire-its/src/test/resources/consoleoutput-noisy/src/test/java/consoleoutput_noisy/Test1.java
@@ -33,10 +33,12 @@ public class Test1
     @Test
     public void test1MillionBytes()
     {
+        System.out.println( "t1 = " + System.currentTimeMillis() );
         for ( int i = 0; i < ( 10 * thousand ); i++ )
         {
             System.out.println( "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" );
         }
+        System.out.println( "t2 = " + System.currentTimeMillis() );
     }
 
     @Test


[maven-surefire] 01/02: improved performance from 320s to 54s.

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch maven2surefire-jvm-communication
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit f4bb445fef2bb32d5281bc793ac96326fab693d9
Author: tibordigana <ti...@apache.org>
AuthorDate: Tue Mar 24 00:57:22 2020 +0100

    improved performance from 320s to 54s.
---
 .../surefire/extensions/EventConsumerThread.java   | 26 +++++++++++++++++-----
 .../surefire/extensions/SurefireForkChannel.java   |  4 +---
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/EventConsumerThread.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/EventConsumerThread.java
index cc33c6c..b92a238 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/EventConsumerThread.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/EventConsumerThread.java
@@ -126,8 +126,9 @@ public class EventConsumerThread extends CloseableDaemonThread
         List<String> tokens = new ArrayList<>();
         StringBuilder line = new StringBuilder();
         StringBuilder token = new StringBuilder( MAGIC_NUMBER.length() );
-        ByteBuffer buffer = ByteBuffer.allocate( 1 );
-        boolean endOfStream;
+        ByteBuffer buffer = ByteBuffer.allocate( 1024 );
+        buffer.position( buffer.limit() );
+        boolean streamContinues;
 
         start:
         do
@@ -136,11 +137,9 @@ public class EventConsumerThread extends CloseableDaemonThread
             tokens.clear();
             token.setLength( 0 );
             FrameCompletion completion = null;
-            for ( boolean frameStarted = false; !( endOfStream = channel.read( buffer ) == -1 ) ; completion = null )
+            for ( boolean frameStarted = false; streamContinues = read( buffer ); completion = null )
             {
-                buffer.flip();
                 char c = (char) buffer.get();
-                buffer.clear();
 
                 if ( c == '\n' || c == '\r' )
                 {
@@ -193,7 +192,7 @@ public class EventConsumerThread extends CloseableDaemonThread
                 }
             }
 
-            if ( endOfStream )
+            if ( !streamContinues )
             {
                 printExistingLine( line );
                 return;
@@ -202,6 +201,21 @@ public class EventConsumerThread extends CloseableDaemonThread
         while ( true );
     }
 
+    private boolean read( ByteBuffer buffer ) throws IOException
+    {
+        if ( buffer.hasRemaining() )
+        {
+            return true;
+        }
+        else
+        {
+            buffer.clear();
+            boolean isEndOfStream = channel.read( buffer ) == -1;
+            buffer.flip();
+            return !isEndOfStream;
+        }
+    }
+
     private void printExistingLine( StringBuilder line )
     {
         if ( line.length() != 0 )
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/SurefireForkChannel.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/SurefireForkChannel.java
index 0aa790c..e11b03f 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/SurefireForkChannel.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/SurefireForkChannel.java
@@ -60,8 +60,6 @@ import static java.nio.channels.ServerSocketChannel.open;
  */
 final class SurefireForkChannel extends ForkChannel
 {
-    private static final byte[] LOCAL_LOOPBACK_IP_ADDRESS = new byte[]{127, 0, 0, 1};
-
     private final ConsoleLogger logger;
     private final ServerSocketChannel server;
     private final int localPort;
@@ -73,7 +71,7 @@ final class SurefireForkChannel extends ForkChannel
         this.logger = logger;
         server = open();
         setTrueOptions( SO_REUSEADDR, TCP_NODELAY, SO_KEEPALIVE );
-        InetAddress ip = Inet4Address.getByAddress( LOCAL_LOOPBACK_IP_ADDRESS );
+        InetAddress ip = Inet4Address.getLoopbackAddress();
         server.bind( new InetSocketAddress( ip, 0 ), 1 );
         localPort = ( (InetSocketAddress) server.getLocalAddress() ).getPort();
     }