AlbumenJ commented on code in PR #11841:
URL: https://github.com/apache/dubbo/pull/11841#discussion_r1139753798


##########
dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/MemorySafeLinkedBlockingQueueTest.java:
##########
@@ -55,4 +56,59 @@ void testCustomReject() {
         assertThrows(RejectException.class, () -> queue.offer(() -> {
         }));
     }
+
+    @Test
+    void testEfficiency() throws InterruptedException {
+        // if length is vert large(unit test may runs for a long time), so you 
may need to modify JVM param such as : -Xms=1024m -Xmx=2048m
+        // if you want to test efficiency of MemorySafeLinkedBlockingQueue, 
you may modify following param: length and times
+        int length = 1000, times = 1;
+
+        // LinkedBlockingQueue insert Integer: 500W * 20 times
+        long spent1 = spend(new LinkedBlockingQueue<>(), length, times);
+
+        // MemorySafeLinkedBlockingQueue insert Integer: 500W * 20 times
+        long spent2 = spend(newMemorySafeLinkedBlockingQueue(),  length, 
times);
+        System.gc();
+        Thread.sleep(1000);

Review Comment:
   Should prevent use `sleep` in unit test



##########
dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/MemorySafeLinkedBlockingQueueTest.java:
##########
@@ -55,4 +56,59 @@ void testCustomReject() {
         assertThrows(RejectException.class, () -> queue.offer(() -> {
         }));
     }
+
+    @Test
+    void testEfficiency() throws InterruptedException {
+        // if length is vert large(unit test may runs for a long time), so you 
may need to modify JVM param such as : -Xms=1024m -Xmx=2048m
+        // if you want to test efficiency of MemorySafeLinkedBlockingQueue, 
you may modify following param: length and times
+        int length = 1000, times = 1;
+
+        // LinkedBlockingQueue insert Integer: 500W * 20 times
+        long spent1 = spend(new LinkedBlockingQueue<>(), length, times);
+
+        // MemorySafeLinkedBlockingQueue insert Integer: 500W * 20 times
+        long spent2 = spend(newMemorySafeLinkedBlockingQueue(),  length, 
times);
+        System.gc();
+        Thread.sleep(1000);
+
+        System.out.println(String.format("LinkedBlockingQueue spent %s millis, 
MemorySafeLinkedBlockingQueue spent %s millis", spent1, spent2));

Review Comment:
   Std out here is useless



##########
dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/MemorySafeLinkedBlockingQueueTest.java:
##########
@@ -55,4 +56,59 @@ void testCustomReject() {
         assertThrows(RejectException.class, () -> queue.offer(() -> {
         }));
     }
+
+    @Test
+    void testEfficiency() throws InterruptedException {
+        // if length is vert large(unit test may runs for a long time), so you 
may need to modify JVM param such as : -Xms=1024m -Xmx=2048m
+        // if you want to test efficiency of MemorySafeLinkedBlockingQueue, 
you may modify following param: length and times
+        int length = 1000, times = 1;
+
+        // LinkedBlockingQueue insert Integer: 500W * 20 times
+        long spent1 = spend(new LinkedBlockingQueue<>(), length, times);
+
+        // MemorySafeLinkedBlockingQueue insert Integer: 500W * 20 times
+        long spent2 = spend(newMemorySafeLinkedBlockingQueue(),  length, 
times);
+        System.gc();
+        Thread.sleep(1000);
+
+        System.out.println(String.format("LinkedBlockingQueue spent %s millis, 
MemorySafeLinkedBlockingQueue spent %s millis", spent1, spent2));

Review Comment:
   Should have at least one assert



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to