You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/09/24 12:37:37 UTC

[GitHub] [pulsar] eolivelli commented on a change in pull request #12020: [testclient] Make option -time take effect in PerformanceClient

eolivelli commented on a change in pull request #12020:
URL: https://github.com/apache/pulsar/pull/12020#discussion_r715574615



##########
File path: pulsar-testclient/src/main/java/org/apache/pulsar/proxy/socket/client/PerformanceClient.java
##########
@@ -244,10 +242,19 @@ public void runPerformanceTest(long messages, long limit, int numOfTopic, int si
         executor.submit(() -> {
             try {
                 RateLimiter rateLimiter = RateLimiter.create(limit);
+                long startTime = System.nanoTime();
+                long testEndTime = startTime + (long) (testTime * 1e9);
                 // Send messages on all topics/producers
                 long totalSent = 0;
                 while (true) {
                     for (String topic : producersMap.keySet()) {
+                        if (testTime > 0 && System.nanoTime() > testEndTime) {
+                            log.info("------------- DONE (reached the maximum duration: [{} seconds] of production) --------------", testTime);
+                            printAggregatedStats();
+                            Thread.sleep(5000);

Review comment:
       Why do you need this Sleep ?

##########
File path: pulsar-testclient/src/main/java/org/apache/pulsar/proxy/socket/client/PerformanceClient.java
##########
@@ -244,10 +242,19 @@ public void runPerformanceTest(long messages, long limit, int numOfTopic, int si
         executor.submit(() -> {
             try {
                 RateLimiter rateLimiter = RateLimiter.create(limit);
+                long startTime = System.nanoTime();
+                long testEndTime = startTime + (long) (testTime * 1e9);
                 // Send messages on all topics/producers
                 long totalSent = 0;
                 while (true) {
                     for (String topic : producersMap.keySet()) {
+                        if (testTime > 0 && System.nanoTime() > testEndTime) {
+                            log.info("------------- DONE (reached the maximum duration: [{} seconds] of production) --------------", testTime);

Review comment:
       this code will be executed by several thread concurrently.
   can we set a flag and print out this like only once ?
   otherwise the effect will not be veryuser-friendly




-- 
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: commits-unsubscribe@pulsar.apache.org

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