[GitHub] maven-surefire pull request #167: Speedup Standard Output if Tests

2017-11-30 Thread DaGeRe
Github user DaGeRe commented on a diff in the pull request:

https://github.com/apache/maven-surefire/pull/167#discussion_r154208805
  
--- Diff: 
surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
 ---
@@ -200,14 +200,8 @@ void sendProps()
 @Override
 public void writeTestOutput( byte[] buf, int off, int len, boolean 
stdout )
 {
-byte[] header = stdout ? stdOutHeader : stdErrHeader;
-byte[] content =
-new byte[buf.length * 3 + 1]; // Hex-escaping can be up to 3 
times length of a regular byte.
-int i = escapeBytesToPrintable( content, 0, buf, off, len );
-content[i++] = (byte) '\n';
-byte[] encodeBytes = new byte[header.length + i];
-System.arraycopy( header, 0, encodeBytes, 0, header.length );
-System.arraycopy( content, 0, encodeBytes, header.length, i );
+final byte[] header = stdout ? stdOutHeader : stdErrHeader;
+final byte[] encodeBytes = escapeBytesToPrintable( header, buf, 
off, len );
--- End diff --

In my experiments, many calls of PrintStream#write lead to a heavily 
decreased performance compared to sending bigger arrays to the PrintStream. 
Therefore, I constructed a big array every time, and this needed differend 
handling.


---

-
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org



[GitHub] maven-surefire pull request #167: Speedup Standard Output if Tests

2017-11-30 Thread Tibor17
Github user Tibor17 commented on a diff in the pull request:

https://github.com/apache/maven-surefire/pull/167#discussion_r154174674
  
--- Diff: 
surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
 ---
@@ -200,14 +200,8 @@ void sendProps()
 @Override
 public void writeTestOutput( byte[] buf, int off, int len, boolean 
stdout )
 {
-byte[] header = stdout ? stdOutHeader : stdErrHeader;
-byte[] content =
-new byte[buf.length * 3 + 1]; // Hex-escaping can be up to 3 
times length of a regular byte.
-int i = escapeBytesToPrintable( content, 0, buf, off, len );
-content[i++] = (byte) '\n';
-byte[] encodeBytes = new byte[header.length + i];
-System.arraycopy( header, 0, encodeBytes, 0, header.length );
-System.arraycopy( content, 0, encodeBytes, header.length, i );
+final byte[] header = stdout ? stdOutHeader : stdErrHeader;
+final byte[] encodeBytes = escapeBytesToPrintable( header, buf, 
off, len );
--- End diff --

Why it is so complex. Why you did not write the stream to 
`PrintStream#write(byte buf[], int off, int len)` and why you did not change 
`escapeBytesToPrintable` so that `header`, 'buf' would go to the method 
parameters and just only one array could be allocated without any copy-paste 
bytes?


---

-
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org



[GitHub] maven-surefire pull request #167: Speedup Standard Output if Tests

2017-10-11 Thread DaGeRe
GitHub user DaGeRe opened a pull request:

https://github.com/apache/maven-surefire/pull/167

Speedup Standard Output if Tests

Currently, surefire creates a new byte array with size of the input *3 for 
saving the unescaped input. This made surefire way slower than running a test 
directly in eclipse or with gradle, if it used standardout or error heavily.
By using a list for saving the elements and converting them to an array 
afterwards, this problem is solved, and stdout-heavy surefire tests get faster.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/DaGeRe/maven-surefire master

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/maven-surefire/pull/167.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #167






---

-
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org