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

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

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


##########
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:
   done, please re-check



##########
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:
   done, please re-check



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