k2la opened a new issue #19: Improve Timing of Promise "then"
URL: https://github.com/apache/pulsar-client-node/issues/19
 
 
   Currently, To measure latency of sending messages,  asynchronous processing 
using Nodejs 
[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
 like following code:
   
   ```
       const results = [];
       for (let mi = 0; mi < numOfMessages; mi += 1) {
         const startSendTimeMilliSeconds = performance.now();
         results.push(producer.send({
           data: message,
         }).then(() => {
           // add latency
           histogram.recordValue((performance.now() - 
startSendTimeMilliSeconds));
         }));
       }
       await Promise.all(results); // wait until all messages are sent.
   ```
   
https://github.com/apache/pulsar-client-node/blob/master/perf/perf_producer.js#L88-L98
   
   This code creates histogram about latency of sending messages.
   However, all `then()` of `Promise` in `results` start after `await 
Promise.all(results)`.
   So, We cannot get accurate histogram.
   
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to