.search method performance

July 6, 2017
Performance improvement

The .search() method is quite useful to understand what you have on the model, but the response time can increase really fast! Imagine if you need to perform multiples searches? But there is a better way: use " (quotes) on your search string. On the image below, we can see how the performance increased by 4! Sure, with quotes it will search for the entire string only, but that might be the case, right? This sample is also restricting the search to "Name" attribute, as per last parameter (an array)

.search method performance

Depending on how big the model is and how many spaces you have on the search string, this difference can be from a couple seconds (with quotes) to a few minutes (without quotes)! 

As you can see on the image, you can run code on the browser console! This is quite useful for quit testing. 

Posts by author

Augusto Goncalves
Developer Advocate, Autodesk

Developer Advocate at Autodesk since 2008, working with both desktop and web/cloud apps using top technologies, like C#, JavaScript, NodeJS and any other that can solve problems and improve workflo