Since my first days in Node-RED, I wanted to develop a node that calculates the sizes of messages passing through, in other words the "throughput" of my flow. But had never time to implement it...
Until last week, when I decided to extract the logic from my node-red-contrib-msg-speed node: now I finally could reuse the entire (rolling window) logic to implement my new node-red-contrib-msg-size node
My personal usage will be monitoring the throughput of my IP camera video streams.
Like in this demo:
For those who want to experiment with it, you can install it from my Github repository from within your .node-red folder (since it hasn't been published on NPM yet!):
It calculates the size of every message running through it.
It sums all those message sizes that arrive during the specified interval
It outputs that "total" size of all messages (within the specified interval) and - as an extra output parameter - it also outputs the "average" size of each message.
Let's take the example from my readme page:
Here the interval specified (in the config screen) is 1 minute. During that minute 3 messages arrive, and their total size = 3 + 5 + 7 = 15 KB per minute (and the average size will be 15 / 3 = 5 KB per minute).
So it is not about counting messages.
If you have any ideas to make this more clear, please share it!!
I don't think you need to worry too much about that as it would only apply to objects containing code - e.g. a function. I think that is discouraged at best and indeed, I'm not even sure it works. That is because the msg has to be serializable and code is not.