You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "AlbumenJ (via GitHub)" <gi...@apache.org> on 2023/03/17 05:19:02 UTC

[GitHub] [dubbo] AlbumenJ commented on a diff in pull request #11841: [ISSUE #10020] test efficiency of MemorySafeLinkedBlockingQueue

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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org