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

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.

You could take a look at these ?

1 Like

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

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

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 !

1 Like

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).

1 Like

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.

How can i get same what I have done in C# ?
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:

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

1 Like

Thanks a lot for the help and 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?

1 Like

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

have you tried Eclipse IDE generated the code?

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

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.

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