Getting the load time of a Tree (Template)

I am tasked with optimizing how fast our tree navigation loads. I have some ideas on how to do this. My boss wants to see the time in seconds it loads now so that we can measure the improvement. The tree is in a template if that makes a difference. How can I get the time from the instant it starts loading to when it’s ready for use?

How is the dataset for the tree being filled?

If it’s via scripting you can use python’s time library at the beginning of the function and end:

import time

begin = time.time()

#do queries/build dataset

print "time taken: %s ms" %(time.time()-begin)

Unfortunately the components I’m optimizing do not all use scripting to populate the data, it’s done just by SQL query. I guess I have to take that query, put it in scripting instead and populate the data that way to do this method correct? There’s no other way right? Tables are the only component I know of that have a propertiesLoading attribute that I could have used in a on property change script.

Instead of moving around queries I decided instead to add a button to my window that clears the data from the components I’m testing and then runs a system.db.refresh(component, “data”) on them, but I’m curious if since I’m doing this post the initial load, is this using some cached db data and the performance is going to look better?

Named queries could be caching on the Ignition side.

But with regular queries, it’s possible for your SQL engine to cache on it’s own, which would be harder to determine.