# Is there a method that can be used to calculate time complexity in Node Red?

**URL:** <https://discourse.nodered.org/t/is-there-a-method-that-can-be-used-to-calculate-time-complexity-in-node-red/75356>\
**Category:** Dashboard\
**Tags:** function-node\
**Created:** [17 February 2023 15:57 UTC](https://discourse.nodered.org/t/is-there-a-method-that-can-be-used-to-calculate-time-complexity-in-node-red/75356 "2023-02-17T15:57:00Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fathi2022](https://avatars.discourse-cdn.com/v4/letter/f/b487fb/32.png) [@Fathi2022](https://discourse.nodered.org/u/Fathi2022)\
**Post date:** [17 February 2023 15:57 UTC](https://discourse.nodered.org/t/is-there-a-method-that-can-be-used-to-calculate-time-complexity-in-node-red/75356/1 "2023-02-17T15:57:00Z")

</div>

Hi All I have a question there is method or property in Node Red Dashboard used to calculate time complexity? For example Visual Studio has code metrics data that calculates the complexity and maintenance.

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [18 February 2023 02:04 UTC](https://discourse.nodered.org/t/is-there-a-method-that-can-be-used-to-calculate-time-complexity-in-node-red/75356/2 "2023-02-18T02:04:02Z")

</div>

You could take a look at these ?

> **[node-red-contrib-interval-length](https://flows.nodered.org/node/node-red-contrib-interval-length)**
>
> A Node Red node to measure the interval length between successive messages

> **[node-red-contrib-msg-speed](https://flows.nodered.org/node/node-red-contrib-msg-speed)**
>
> A Node Red node to measure the flow message speed, i.e. the rate at which messages arrive

---

<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:** [18 February 2023 09:22 UTC](https://discourse.nodered.org/t/is-there-a-method-that-can-be-used-to-calculate-time-complexity-in-node-red/75356/3 "2023-02-18T09:22:00Z")

</div>

Beside that I think this one can also give you some usefull feedback:

> **[GitHub - bartbutenaers/node-red-contrib-msg-profiler: A Node-RED node to...](https://github.com/bartbutenaers/node-red-contrib-msg-profiler)**
>
> A Node-RED node to execute time profiling (and tracing) of a message through a flow - GitHub - bartbutenaers/node-red-contrib-msg-profiler: A Node-RED node to execute time profiling (and tracing) o...

Note that it is not available via npm, so you need to install it via command line.

When I ask _ **chatgpt** _ how he would do it, I get this:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/d/1da2265067662acc5ad6f5ca45b10794163c8140.png)

By using my node-red-contrib-msg-profiler you need to start profiling all your node chains manually. I "think" there are no metrics available that give you this kind of information out of the box for all your Node-RED flows, although I might be mistaken. It all depends on your number of messages, the content of your messages, which nodes your are using, the configuration of those nodes, and so on...

Good luck hunting !

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [18 February 2023 21:59 UTC](https://discourse.nodered.org/t/is-there-a-method-that-can-be-used-to-calculate-time-complexity-in-node-red/75356/4 "2023-02-18T21:59:54Z")

</div>

If by time complexity you mean how quickly the execution time grows with the "size" of the input, that's hard to measure and almost certainly cannot be found by just inspecting the code. A quick look at the VS metrics doesn't show anything along those lines. On the other hand, something like the structural complexity measure ("cyclomatic complexity") they describe could probably be computed from a NR flow JSON by counting the number of nodes with more than one wire (or link).

---

<div class="post-metadata">

**Author:** ![Fathi2022](https://avatars.discourse-cdn.com/v4/letter/f/b487fb/32.png) [@Fathi2022](https://discourse.nodered.org/u/Fathi2022)\
**Post date:** [19 February 2023 17:11 UTC](https://discourse.nodered.org/t/is-there-a-method-that-can-be-used-to-calculate-time-complexity-in-node-red/75356/5 "2023-02-19T17:11:46Z")

</div>

i have 2 experiment using C# and Node RED to read XML file so I have to use same method for both is that right? In C# I have used Code metric which is a library to calculate time complexity for the code.  
So i need to use library for get time complicity of the code.

---

<div class="post-metadata">

**Author:** ![Fathi2022](https://avatars.discourse-cdn.com/v4/letter/f/b487fb/32.png) [@Fathi2022](https://discourse.nodered.org/u/Fathi2022)\
**Post date:** [19 February 2023 18:28 UTC](https://discourse.nodered.org/t/is-there-a-method-that-can-be-used-to-calculate-time-complexity-in-node-red/75356/6 "2023-02-19T18:28:40Z")

</div>

How can i get same what I have done in C# ?  
Cyclometric Complexity and Line of Source Code

 ![IMG-20230217-WA0023](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/1/81d34eca3f9e504d00f3a68483d81701727c920a.jpeg)

---

<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:** [19 February 2023 19:38 UTC](https://discourse.nodered.org/t/is-there-a-method-that-can-be-used-to-calculate-time-complexity-in-node-red/75356/7 "2023-02-19T19:38:51Z")

</div>

> [@Fathi2022](#):
>
> Cyclometric Complexity and Line of Source Code

Hmm, I spend for my daily job lots of time between all kind of metrics, but I have doubts about the added value of these kind of metrics in real life. Anyway doesn't matter, only my personal opinion.

Well to be honest I don't have any clue. Your messages run through your nodes in your flow. And those nodes can also be contributed node, which are separate npm modules. So you would need to find a way to search through all those modules.

Since I have no clue, I again asked chatgpt and he indeed proposes to use eslint to analyze these npm modules:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/f/efad469dc74dce68ac0c22ba82fcf489ac9ffff5.png)

But I can't help you further with this. Good luck!

---

<div class="post-metadata">

**Author:** ![Fathi2022](https://avatars.discourse-cdn.com/v4/letter/f/b487fb/32.png) [@Fathi2022](https://discourse.nodered.org/u/Fathi2022)\
**Post date:** [19 February 2023 19:56 UTC](https://discourse.nodered.org/t/is-there-a-method-that-can-be-used-to-calculate-time-complexity-in-node-red/75356/8 "2023-02-19T19:56:57Z")

</div>

Thanks a lot for the help and now is better than before

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [19 February 2023 21:47 UTC](https://discourse.nodered.org/t/is-there-a-method-that-can-be-used-to-calculate-time-complexity-in-node-red/75356/9 "2023-02-19T21:47:41Z")

</div>

> [@Fathi2022](#):
>
> now is better than before

Could you be more specific? Have you got something working? I was not able to find the eslint-plugin-node-red that chatGPT mentions on npm. Or are you using something else?

---

<div class="post-metadata">

**Author:** ![Fathi2022](https://avatars.discourse-cdn.com/v4/letter/f/b487fb/32.png) [@Fathi2022](https://discourse.nodered.org/u/Fathi2022)\
**Post date:** [6 March 2023 15:45 UTC](https://discourse.nodered.org/t/is-there-a-method-that-can-be-used-to-calculate-time-complexity-in-node-red/75356/10 "2023-03-06T15:45:04Z")

</div>

No i am still working on it i did not find way to calculate time complexity In Node Red .  
i think we need to use Big O is more clear

---

<div class="post-metadata">

**Author:** ![Fathi2022](https://avatars.discourse-cdn.com/v4/letter/f/b487fb/32.png) [@Fathi2022](https://discourse.nodered.org/u/Fathi2022)\
**Post date:** [10 March 2023 18:57 UTC](https://discourse.nodered.org/t/is-there-a-method-that-can-be-used-to-calculate-time-complexity-in-node-red/75356/11 "2023-03-10T18:57:50Z")

</div>

have you tried Eclipse IDE generated the code?

---

<div class="post-metadata">

**Author:** ![Fathi2022](https://avatars.discourse-cdn.com/v4/letter/f/b487fb/32.png) [@Fathi2022](https://discourse.nodered.org/u/Fathi2022)\
**Post date:** [10 March 2023 19:05 UTC](https://discourse.nodered.org/t/is-there-a-method-that-can-be-used-to-calculate-time-complexity-in-node-red/75356/12 "2023-03-10T19:05:48Z")

</div>

use JavaScript code within a function node to calculate time complexity by measuring the execution time of your code using the `performance.now()` method

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [10 March 2023 19:32 UTC](https://discourse.nodered.org/t/is-there-a-method-that-can-be-used-to-calculate-time-complexity-in-node-red/75356/13 "2023-03-10T19:32:29Z")

</div>

> [@Fathi2022](#):
>
> measuring the execution time

Complexity is not measured by execution time but by the increase in time as the "size" of the problem grows. The hard part is determining how "big" a problem is, providing problems of different size, and measuring over a sufficient range.

---

<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:** [9 April 2023 19:33 UTC](https://discourse.nodered.org/t/is-there-a-method-that-can-be-used-to-calculate-time-complexity-in-node-red/75356/14 "2023-04-09T19:33:28Z")

</div>

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