I always wanted to compare these two functions to see which won, and spoiler alert, it's system.tag.browse by more than an order of magnitude! At least for my very small site and test case...
Thanks for this writeup! Just including a note for others if they decide to test this as well, don't include a wildcard character (*) in the path (first argument) of the system.tag.browse() call, since it needs to be the starting folder for the search. This is in contrast to the "Tag Path" field of the Tag Report Tool, which does accept * as a wildcard.
If curious, my test results was roughly
.query = 522ms
.browse = 174ms
Note that my Ignition designer was remotely connected to my test site, which had over 20,000 tags. So, this is probably a "Your mileage may vary" situation, but interesting to explore more. I usually go with .query for the ease of setup, but I will have to give .browse a try again sometime.
I tried pretty much the same thing to test the speed of both functions, and came to the same conclusion: browse is much faster than query. It's not even close.
But then I tried running them out of a loop, just one call at once, and I noticed something: browse's execution time is rather stable. I get around 0.08 secs. Sometimes it goes up to 0.1 secs, but it stays in that ballpark. query, on the other hand, varies wildly. I can get results in 0.01 secs one time, and 0.3 secs on the next call. That's 30 times longer on the 2nd call !
I was kinda hoping to replace some browse calls with query, the added flexibility in the filtering would be helpful in some cases, but I guess I'll stick with it for now.
Use .query when you want to recurse into the tree. Use .browse() when you don't. Unless you want to grab a bunch of properties. Then using .query() is usually faster than .browse() followed by .readBlocking().
I'm only discovering this function, I completely missed its introduction, so I have to experiment with it a bit, but...
What if I want to read tags in a UDT instance ? Or its parameters ? I can't find a way to do that with query.
Assuming I'll still have to use readBlocking to get their values, should I use query or browse to get the UDT instances paths ?
system.tag.query() is the fundamental backing of the Designer's Tag Report Tool. Use that to get a feel for how it works. Yes, it has settings for searching within UDT instances. That tool will also write the sample jython that corresponds to what you've set up.