# Measure how long your flow takes to execute

**URL:** <https://discourse.nodered.org/t/measure-how-long-your-flow-takes-to-execute/24719>\
**Category:** General\
**Created:** [12 April 2020 21:05 UTC](https://discourse.nodered.org/t/measure-how-long-your-flow-takes-to-execute/24719 "2020-04-12T21:05:44Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ScheepersJohan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/scheepersjohan/32/39556_2.png) [@ScheepersJohan](https://discourse.nodered.org/u/ScheepersJohan)\
**Post date:** [12 April 2020 21:05 UTC](https://discourse.nodered.org/t/measure-how-long-your-flow-takes-to-execute/24719/1 "2020-04-12T21:05:44Z")

</div>

Hi,

How do you measure how long it takes to execute your flow? (Understand that there are loops and other factors) But there are various ways of doing something, some take more time than others.

So basically looking at a way to measure if I have improved my flow.

Thanks

---

<div class="post-metadata">

**Author:** ![JGKK](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jgkk/32/18515_2.png) [@JGKK](https://discourse.nodered.org/u/JGKK)\
**Post date:** [12 April 2020 21:14 UTC](https://discourse.nodered.org/t/measure-how-long-your-flow-takes-to-execute/24719/2 "2020-04-12T21:14:48Z")

</div>

I would attach a timestamp to a message property like msg.timestamp or a flow var at the start of the flow and put a function node at the end that gets a new timestamp and calculates the difference between the two and outputs it as msg.runtime for example.

Johannes

---

<div class="post-metadata">

**Author:** ![hominidae](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hominidae/32/4174_2.png) [@hominidae](https://discourse.nodered.org/u/hominidae)\
**Post date:** [12 April 2020 21:22 UTC](https://discourse.nodered.org/t/measure-how-long-your-flow-takes-to-execute/24719/3 "2020-04-12T21:22:03Z")

</div>

...I'd use this node: [https://flows.nodered.org/node/node-red-contrib-interval-length](https://flows.nodered.org/node/node-red-contrib-interval-length) ... note that it can use the flow start for a trigger trigger as well.

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [12 April 2020 21:55 UTC](https://discourse.nodered.org/t/measure-how-long-your-flow-takes-to-execute/24719/4 "2020-04-12T21:55:40Z")

</div>

> [@hominidae](#):
>
> I'd use this node: [https://flows.nodered.org/node/node-red-contrib-interval-length](https://flows.nodered.org/node/node-red-contrib-interval-length) ... note that it can use the flow start for a trigger trigger as well

I'm not sure if this node can be used for this purpose, but perhaps you could...  
I developed that node for measuring the timings between successive messages. Optionally you can measure the timing between the flow start and the 'first' message.  
But if it is useful to measure the performance of a flow, please share here how you did use it. Thanks!

P.S. Have not used it myself, but perhaps the Node-RED [metrics](https://nodered.org/docs/user-guide/runtime/logging#metrics) could be used to compare timings of flow versions?

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [12 April 2020 22:14 UTC](https://discourse.nodered.org/t/measure-how-long-your-flow-takes-to-execute/24719/5 "2020-04-12T22:14:35Z")

</div>

I suppose any readings obtained by either adding timestamps or using metrics will only be a rough guide, as their granularity is displayed in milliseconds.  
So unless the flow is particularly slow, the results are not going to be accurate.

---

<div class="post-metadata">

**Author:** ![ScheepersJohan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/scheepersjohan/32/39556_2.png) [@ScheepersJohan](https://discourse.nodered.org/u/ScheepersJohan)\
**Post date:** [13 April 2020 06:59 UTC](https://discourse.nodered.org/t/measure-how-long-your-flow-takes-to-execute/24719/6 "2020-04-13T06:59:06Z")

</div>

Thanks, from the metrics I can see the time the first node starts to where the last node stops, it is a bit of a manual process to determine the time it takes, but never the less a way to tell.

Thank you

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [13 April 2020 09:49 UTC](https://discourse.nodered.org/t/measure-how-long-your-flow-takes-to-execute/24719/7 "2020-04-13T09:49:59Z")

</div>

As with many metrics/logs the expectation was that at some point someone would write a nifty tool to help analyse the log, to help show hotspots, bottlenecks, breaks, etc etc... but you know, time, time, time.

---

<div class="post-metadata">

**Author:** ![ScheepersJohan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/scheepersjohan/32/39556_2.png) [@ScheepersJohan](https://discourse.nodered.org/u/ScheepersJohan)\
**Post date:** [14 April 2020 05:01 UTC](https://discourse.nodered.org/t/measure-how-long-your-flow-takes-to-execute/24719/8 "2020-04-14T05:01:15Z")

</div>

That will be brilliant 😃

If I calculate manually my flow it takes abort 4576ms +/- (fairly constant over to instances).

The fist node I could predict (as it is a inject node that starts the process) but the last node were a debug that I did not expect to be the last, it is consistently the last one.

Will be nice to see the hotspots, bottlenecks, breaks, etc, as to do these manually are difficult.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [13 June 2020 05:01 UTC](https://discourse.nodered.org/t/measure-how-long-your-flow-takes-to-execute/24719/9 "2020-06-13T05:01:21Z")

</div>

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