July 6, 2017

.search method performance

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. 

Related Posts

July 11, 2019

New Autodesk Forge Viewer 7.0 is Now Available

Autodesk Forge is our collection of Application Program Interfaces (APIs), documentation, sample code, and a community of cust

Read More

July 10, 2019

Look for exact property value and more

When using the search() function of the Viewer, you can only look for strings that at least partially match a given value.

Read More

July 9, 2019

Webpack and three.js in forge applications

In the newer versions of forge viewers( v6 and above) three.js is included in the forge viwer js file itself.

Read More