Very interesting question!
Would be nice if you could measure the cpu of each Node-RED block, instead of having to use trial-and-error. But I'm not sure whether you can do that, because I 'think' it works like this:
- A Node-RED block will execute some code (synchronous) => I think you could (somehow) measure the CPU usage required to execute this code.
- But in that code other code could be called asynchronous => this code will be executed afterwards by the event loop => You would have to measure this CPU usage also, since it has been triggered originally by the Node-RED node.
- And that previous asynchronous code, can again call another code snippet asynchronously.
- And so on ...
So you would have to keep track somehow of all code that has been triggered by the Node-RED node, and then sum all those cpu usages to calculate the cpu usage of that Node-RED node. And this process needs to be repeated for all nodes in your flow. Then you would have a nice overview of how much cpu each of your Node-RED nodes uses.
But no idea how to measure that
I assume you need a CPU profiler. For example if we have a look at the output of this (obsolete!!!) async-profile module:
It seems to me that it keeps track of all asynchronous calls, and at the end all cpu usages are aggregated. But I have never digged into NodeJs cpu profilers...