How to measure the delay in node red between the mqtt gateway

I am new to node red .
I would like to know if there is a node that can be used to measure the delay between the nodes in node red flow

There is a nice simple subflow you can import and use to measure time between 2 points...

Thank you for your reply. I will work with it .

Is it possible to store the values of the start and end values from the flow timer

sure, you can do anything.

As it states in the readme the results are delivered in the msg and stored in global context...

The results (msg)...


The results (global)...


You can do whatever you want with them

Thank you .i will try it

I have one more question regarding the flow timer , when it measure the start time and stop time does it inputs any delay ?
ie,the duration is the time taken just to complete the flow or does the flow timer node add any extra time.

I am 100% certain this node will add some time (it is code after all) but is likely immeasurable (like 1 ms or less). Why not give it a go? Put a start and a stop without anything in between. Run it a few times. What value do you get? If you consistently get 2ms then either deduct 2ms from other results or accept it is good for +/- 2ms.

If you are after solid accuracy with zero jitter and determinism, then you are on the wrong platform :wink:

My recommendation is when assessing the performance of a piece of code is first - don't (unless you know you have a problem). Next, run the timer against multiple (hundreds/thousands) of iterations several times over (to get an average).

1 Like

Ok .Thank you once again for explaining in detail.

I have 1 more question ,in the document it is given the time is measured in MS but is there any way to measure it in microseconds?

Sure, if you modify it to use performance hooks or process.hrtime.

But seriously, what are you trying to measure?

Not with that node. In theory you could create your own functions and use the nodejs hrtime capability to do it - but then you really will be into the timing of the actual measurement calls affecting the result. And given that nodejs is running async processes on top of a non-realtime operating system there will potentially be lots of other things occurring in the system that would affect the accuracy tolerance of any measurement. As @Steve-Mcl suggested the simplest way would really to measure many thousands of operations and then divide... but one has to ask why do you need such accuracy ?

So i am trying to find delay in a mqtt gateway .

thank you for your reply. It is just that i wanted to know how much accurate it is .But as @Steve-Mcl answered i tried as he said and understood that the node will add some time .

Do you mean between a publish and receiving the new value?

How consistent are the figures that you are getting? There is no point going to microseconds unless the millisecond figure is consistent.

Sorry for the late response.
Actually i have not started with mqtt part .
As a beginner ,i am just trying with some samples flows and trying to understand the working.

i have one question regarding the storing of data. As you mentioned that values can be stored in global context.
is it possible to export into the excel .
I did some research and found a node called csv .But is it possible to get the start,stop and duration values into the excel.

Please start a new thread since this is a new topic.

Okay .i shall start a new thread

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.