Performance quesrion re date and time in lots of flows

#1

Guys,

If i end up with lots of lfows that are accessing Date and or time for functions and for logging etc - am i better off having a single Node on a flow that sets a global date and time object (in my desirred format) and then access that object from my flows when/where needed, or am i better off using and accessing the date and time in each flow (either through the native JS functions in a function node) or through the moment node ? Or does it not matter in the overall scheme of things.

I am running on a VM on a HP Microserver under Ubuntu 18.04

Craig

#2

The main issue here, I think, is not the performance but actually whether you need a SINGLE date/time value - e.g. is your flow time-critical enough to force you to use a single value throughout.

The second question is whether you have a single flow or many. If only a single flow, then simply add a timestamp to the msg and let it flow through. If you have many flows, then you will want to put your single value into a variable but you will have to watch out for timing issues.

If you are using a simple JS date/time value, I don't believe you will really notice any performance issues unless you are generating many thousands of values.

Things will be slightly different if you are using moment since it is rather more heavyweight. I still think you would struggle to notice any performance issues but I guess if your flows are REALLY big, you might.

Bottom line: Do you want a single, universal date/time value or not? Is your processing likely to be sensitive to a second or so difference in values?

#3

Nope not time critical like that - there will be lots of flows that will use the time for logging or making decisions etc - but if i was to updated a global memory variable every 10 seconds for instance that would be good enough in terms of logging to files etc.

Craig

#4

I can't imagine that reading from global context is any faster than asking JS to give you the current date, so I would probably skip the overhead of having a flow just to keep a timestamp in memory.

Where timestamps get tedious is in the formatting, say for logging or display purposes. You may want to look at this simpletime node which provides many useful versions of components of the current timestamp for you.

#5

Thanks Steve - will do

Craig

#6

Which timestamp format do you need?
Something like following is quite easy to build with js or jsonata:

YYYY-MM-DD_hh:mm:ss
#7

Is there any special reason, why you dont try it out?

It should be pretty easy to simulate the desired behavior - maybe with a rapid prototyping graphical tool?

oh wait... :slight_smile:

1 Like
#8

Much better to use ISO/Internet time format:

yyyy-mm-ddThh:mm:ssZ

https://tools.ietf.org/search/rfc3339

This is parsable and understood widely.

#9

Yep thats the format i am using !

#10

:smiley::smiley::smiley:

Yep already have it running - just wondering if i was going to run over a cliff at some point in the future so doing a sanity check !

Craig