Skip to content

Commit f8092e9

Browse files
committed
Improve time units
1 parent c670335 commit f8092e9

File tree

15 files changed

+36
-35
lines changed

15 files changed

+36
-35
lines changed

Diff for: maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public void kill() {
280280
* Called in concurrent Thread.
281281
* Will shutdown if timeout was reached.
282282
*
283-
* @param currentTimeMillis current time in millis seconds
283+
* @param currentTimeMillis current time in milliseconds
284284
* @param forkedProcessTimeoutInSeconds timeout in seconds given by MOJO
285285
*/
286286
public void tryToTimeout(long currentTimeMillis, int forkedProcessTimeoutInSeconds) {

Diff for: maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
* <br>
3939
* After applying the performance improvements with {@link QueueSynchronizer} the throughput becomes
4040
* 6.33 mega messages per second
41-
* (158 nano seconds per message, 5 million messages within 0.79 seconds - see the test ThreadedStreamConsumerTest)
41+
* (158 nanoseconds per message, 5 million messages within 0.79 seconds - see the test ThreadedStreamConsumerTest)
4242
* on CPU i5 Dual Core 2.6 GHz and Oracle JDK 11.
4343
*
4444
* @author Kristian Rosenvold
@@ -114,7 +114,7 @@ public ThreadedStreamConsumer(EventHandler<Event> target) {
114114
@Override
115115
public void handleEvent(@Nonnull Event event) {
116116
// Do NOT call Thread.isAlive() - slow.
117-
// It makes worse performance from 790 millis to 1250 millis for 5 million messages.
117+
// It makes worse performance from 790 ms to 1250 ms for 5 million messages.
118118
if (!stop.get() && isAlive.get()) {
119119
synchronizer.pushNext(event);
120120
}

Diff for: maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumerTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void run() {
7373
assertThat(countDown.await(3L, SECONDS)).isTrue();
7474

7575
long t2 = System.currentTimeMillis();
76-
System.out.println((t2 - t1) + " millis in testQueueSynchronizer()");
76+
System.out.println("spent " + (t2 - t1) + " ms in testQueueSynchronizer()");
7777
}
7878

7979
@Test
@@ -102,7 +102,7 @@ public void handleEvent(@Nonnull Event event) {
102102
assertThat(countDown.await(3L, SECONDS)).isTrue();
103103

104104
long t2 = System.currentTimeMillis();
105-
System.out.println((t2 - t1) + " millis in testThreadedStreamConsumer()");
105+
System.out.println("spent " + (t2 - t1) + " ms in testThreadedStreamConsumer()");
106106

107107
streamConsumer.close();
108108
}

Diff for: maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/extensions/E2ETest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public void handleEvent(@Nonnull Event event) {
105105

106106
if (counter.get() == totalCalls - 64 * 1024) {
107107
readTime.set(spent);
108-
System.out.println(spent + "ms on read");
108+
System.out.println("spent " + spent + " ms on read");
109109
awaitHandlerFinished.countDown();
110110
}
111111
} catch (Exception e) {
@@ -148,7 +148,7 @@ public void writeTestOutput(OutputReportEntry reportEntry) {
148148
long spent = t2 - t1;
149149
// System.setOut( out );
150150
// System.setErr( err );
151-
System.out.println(spent + "ms on write");
151+
System.out.println("spent " + spent + " ms on write");
152152
awaitHandlerFinished.countDown();
153153
} catch (Exception e) {
154154
e.printStackTrace();
@@ -166,8 +166,8 @@ public void writeTestOutput(OutputReportEntry reportEntry) {
166166

167167
// 1.0 seconds while using the encoder/decoder
168168
assertThat(readTime.get())
169-
.describedAs("The performance test should assert 1.0s of read time. "
170-
+ "The limit 6s guarantees that the read time does not exceed this limit on overloaded CPU.")
169+
.describedAs("The performance test should assert 1.0 s of read time. "
170+
+ "The limit 6 s guarantees that the read time does not exceed this limit on overloaded CPU.")
171171
.isPositive()
172172
.isLessThanOrEqualTo(6_000L);
173173
}

Diff for: maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/extensions/EventConsumerThreadTest.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,13 @@ public synchronized int read(ByteBuffer dst) {
112112
thread.join();
113113

114114
long execTime = finishedAt[0] - staredAt[0];
115-
System.out.println(execTime);
115+
System.out.println("...executed in " + execTime + " ms");
116116

117117
// 0.6 seconds while using the encoder/decoder for 10 million messages
118118
assertThat(execTime)
119-
.describedAs("The performance test should assert 0.75s of read time. "
120-
+ "The limit 3.65s guarantees that the read time does not exceed this limit on overloaded CPU.")
119+
.describedAs(
120+
"The performance test should assert 0.75 s of read time. "
121+
+ "The limit 3.65 s guarantees that the read time does not exceed this limit on overloaded CPU.")
121122
.isPositive()
122123
.isLessThanOrEqualTo(3_650L);
123124
}

Diff for: surefire-api/src/main/java/org/apache/maven/surefire/api/report/ReportEntry.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public interface ReportEntry {
7171
* Gets the runtime for the item. Optional parameter. If the value is not set, it will be determined within
7272
* the reporting subsystem. Some providers like to calculate this value themselves, and it gets the
7373
* most accurate value.
74-
* @return duration of a test in milli seconds
74+
* @return duration of a test in milliseconds
7575
*/
7676
Integer getElapsed();
7777

Diff for: surefire-api/src/main/java/org/apache/maven/surefire/api/util/SureFireFileManager.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ private static TempFileManager create() {
3636
String subDirName = "surefire";
3737

3838
// create directory name suffix from legal chars in the current user name
39-
// or a millisecond timestamp as fallback
39+
// or a timestamp with millisecond resolution as fallback
4040
String userSuffix = Stream.of("user.name", "USER", "USERNAME")
4141
.map(System::getProperty)
4242
.filter(Objects::nonNull)

Diff for: surefire-api/src/test/java/org/apache/maven/surefire/api/stream/AbstractStreamDecoderTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ public void shouldDecode100Bytes() throws Exception {
372372
((Buffer) chars).clear();
373373
}
374374
long l2 = System.currentTimeMillis();
375-
System.out.println("decoded 100 bytes within " + (l2 - l1) + " millis (10 million cycles)");
375+
System.out.println("decoded 100 bytes within " + (l2 - l1) + " ms (10 million cycles)");
376376
assertThat(s).isEqualTo(PATTERN1);
377377
}
378378

Diff for: surefire-api/src/test/java/org/apache/maven/surefire/api/util/internal/AsyncSocketTest.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,13 @@ public void run() {
133133
long spent = t2 - t1;
134134

135135
if (i % 100_000 == 0) {
136-
System.out.println(spent + "ms: " + i);
136+
System.out.println("spent " + spent + " ms: " + i);
137137
}
138138
}
139139
os.flush();
140140
long spent = System.currentTimeMillis() - t1;
141141
writeTime.set(spent);
142-
System.out.println(spent + "ms: " + i);
142+
System.out.println("spent " + spent + " ms: " + i);
143143
} catch (IOException e) {
144144
e.printStackTrace();
145145
}
@@ -156,12 +156,12 @@ public void run() {
156156
worker.close();
157157
server.close();
158158

159-
// 160 millis on write using the asynchronous sockets
160-
// 320 millis on NIO blocking sockets
159+
// 160 milliseconds on write using the asynchronous sockets
160+
// 320 milliseconds on NIO blocking sockets
161161
assertThat(writeTime.get()).isLessThan(1000L);
162162

163-
// 160 millis on read using the asynchronous sockets
164-
// 320 millis on NIO blocking sockets
163+
// 160 milliseconds on read using the asynchronous sockets
164+
// 320 milliseconds on NIO blocking sockets
165165
assertThat(readTime.get()).isLessThan(1000L);
166166
}
167167

@@ -181,8 +181,8 @@ private void client() throws Exception {
181181
long t2 = System.currentTimeMillis();
182182
long spent = t2 - t1;
183183
readTime.set(spent);
184-
System.out.println(new String(bytes.get(bytes.size() - 1)));
185-
System.out.println("received within " + spent + "ms");
184+
System.out.println("string read: " + new String(bytes.get(bytes.size() - 1)));
185+
System.out.println("received within " + spent + " ms");
186186
clientSocketChannel.close();
187187
barrier.countDown();
188188
}

Diff for: surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public void shouldHavePid() throws Exception {
122122
? unixProcessInfo(expectedPid, 0L)
123123
: windowsProcessInfo(expectedPid, windowsProcessStartTime(checker)));
124124

125-
// the etime in Unix is measured in seconds. So let's wait 1s at least.
125+
// the etime in Unix is measured in seconds. So let's wait 1 s at least.
126126
SECONDS.sleep(1L);
127127

128128
ProcessInfo processInfo = IS_OS_UNIX ? checker.unix() : checker.windows();

Diff for: surefire-its/src/test/resources/reporters/src/test/java/reporters/Test1.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
public class Test1 extends TestCase
66
{
77
public void test6281() {
8-
System.out.println( "Test1 on" + Thread.currentThread().getName());
8+
System.out.println( "Test1 on " + Thread.currentThread().getName());
99
}
1010

1111
}

Diff for: surefire-its/src/test/resources/reporters/src/test/java/reporters/Test2.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525
public class Test2 extends TestCase
2626
{
2727
public void test6281() {
28-
System.out.println( "Test2 on" + Thread.currentThread().getName());
28+
System.out.println( "Test2 on " + Thread.currentThread().getName());
2929
}
3030
}

Diff for: surefire-its/src/test/resources/testng-parallel-with-annotations/src/test/java/testng/paralellwithannotations/TestNGParallelTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void checkTestResults()
5454
assertTrue( testCount == INVOCATION_COUNT, "Expected test to be run 3 times, but was " + testCount );
5555
// Note, this can be < 6000 on Windows.
5656
assertTrue( runtime < INVOCATION_COUNT * DELAY - 300L,
57-
"Runtime was " + runtime + ". It should be a little over 3000ms but less than 6000ms." );
57+
"Runtime was " + runtime + ". It should be a little over 3000 ms but less than 6000 ms." );
5858
}
5959

6060
@Test( threadPoolSize = THREAD_POOL_SIZE, invocationCount = INVOCATION_COUNT )

Diff for: surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilderTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ public void separatePoolsWithSuiteAndClass() {
288288

289289
// 6 methods altogether.
290290
// 2 groups with 3 threads.
291-
// Each group takes 0.5s.
291+
// Each group takes 0.5 s.
292292
ParallelComputerBuilder.PC computer = (ParallelComputerBuilder.PC) parallelComputerBuilder.buildComputer();
293293
final JUnitCore core = new JUnitCore();
294294
final long t1 = systemMillis();

Diff for: surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtilTest.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -912,8 +912,8 @@ public void withoutShutdown() {
912912

913913
@Test
914914
public void shutdown() throws TestSetFailedException {
915-
// The JUnitCore returns after 2.5s.
916-
// The test-methods in TestClass are NOT interrupted, and return normally after 5s.
915+
// The JUnitCore returns after 2.5 s.
916+
// The test-methods in TestClass are NOT interrupted, and return normally after 5 s.
917917
Map<String, String> properties = new HashMap<>();
918918
properties.put(PARALLEL_KEY, "methods");
919919
properties.put(THREADCOUNTMETHODS_KEY, "2");
@@ -937,7 +937,7 @@ public void shutdown() throws TestSetFailedException {
937937

938938
@Test
939939
public void forcedShutdown() throws TestSetFailedException {
940-
// The JUnitCore returns after 2.5s, and the test-methods in TestClass are interrupted.
940+
// The JUnitCore returns after 2.5 s, and the test-methods in TestClass are interrupted.
941941
Map<String, String> properties = new HashMap<>();
942942
properties.put(PARALLEL_KEY, "methods");
943943
properties.put(THREADCOUNTMETHODS_KEY, "2");
@@ -961,9 +961,9 @@ public void forcedShutdown() throws TestSetFailedException {
961961

962962
@Test
963963
public void timeoutAndForcedShutdown() throws TestSetFailedException {
964-
// The JUnitCore returns after 3.5s and the test-methods in TestClass are timed out after 2.5s.
965-
// No new test methods are scheduled for execution after 2.5s.
966-
// Interruption of test methods after 3.5s.
964+
// The JUnitCore returns after 3.5 s and the test-methods in TestClass are timed out after 2.5 s.
965+
// No new test methods are scheduled for execution after 2.5 s.
966+
// Interruption of test methods after 3.5 s.
967967
Map<String, String> properties = new HashMap<>();
968968
properties.put(PARALLEL_KEY, "methods");
969969
properties.put(THREADCOUNTMETHODS_KEY, "2");
@@ -988,7 +988,7 @@ public void timeoutAndForcedShutdown() throws TestSetFailedException {
988988

989989
@Test
990990
public void forcedTimeoutAndShutdown() throws Exception {
991-
// The JUnitCore returns after 3.5s and the test-methods in TestClass are interrupted after 3.5s.
991+
// The JUnitCore returns after 3.5 s and the test-methods in TestClass are interrupted after 3.5 s.
992992
Map<String, String> properties = new HashMap<>();
993993
properties.put(PARALLEL_KEY, "methods");
994994
properties.put(THREADCOUNTMETHODS_KEY, "2");

0 commit comments

Comments
 (0)