question

Tomi Kosunen avatar image
0 Likes"
Tomi Kosunen asked Jordan Johnson answered

Performance Profiler AND model.find command

Hi

I found out that Performance Profiler creates new node into model tree: ProfileData. All the objects (Processors etc) are named there. If I then use command model.find("?Processor"); in the code somewhere, it does not find the Object Processor (as it does before running the Performance Profiler ), but it finds the treenode under ProfileData. What would be the best way to handle this situation?

The problem does not occur, if the Processor is directly under model. But it the Processor is inside a plane, then it happens.

BTW: what is the difference between model.find("Processor1"); and Model.find("Processor");?


1646218983868.png



FlexSim 22.0.0
performance profiler
1646218983868.png (20.6 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jordan Johnson avatar image
0 Likes"
Jordan Johnson answered

@Jason Lightfoot has the right idea. The best solution is to not use the ? when you use find(). It can be really, really slow. As you have discovered, it searches the tree recursively until it finds something that matches. This means that find("?Processor1") would check the entire tools folder, including every cell in every global table, and every activity in every process flow, searching for a node named "Processor1". It seems like there are many, many other ways to get a reference to that node, that wouldn't require a search like that.

The fastest workaround is to delete the profile data. Nothing references it besides the view. With the model not running, start recording a new profile and stop it again. Or just delete the whole folder from the tree directly. But I strongly encourage you to avoid using the "?".

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Jason Lightfoot edited

I think it's probably not best practice to assume that there's only one object of that name in your model and that it uniquely identifies it - however a unique path is a valid assumption (although not guaranteed). So in your case I would be searching for Plane6162/Processor1.

Also in a very large model I wouldn't want to be using find to locate objects by their name, and would instead store pointers to the objects in labels or lists (or, at a push, connections). That way anyone can change the name to be something more meaningful or descriptive at any point and your model won't break.

model() returns the treenode that is the model object, while Model is the class. They will both do the same thing when used with find()

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.