# Performance benefit in using array locator method

**URL:** <https://verificationacademy.com/forums/t/performance-benefit-in-using-array-locator-method/38959>\
**Category:** SystemVerilog\
**Tags:** array-locator-method, array-manipulation-methods, SystemVerilog\
**Created:** [April 9, 2021, 4:33am UTC](https://verificationacademy.com/forums/t/performance-benefit-in-using-array-locator-method/38959 "2021-04-09T04:33:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Omkar](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/o/bb73d2/32.png) [@Omkar](https://verificationacademy.com/forums/u/Omkar)\
**Post date:** [April 9, 2021, 4:33am UTC](https://verificationacademy.com/forums/t/performance-benefit-in-using-array-locator-method/38959/1 "2021-04-09T04:33:56Z")

</div>

Hi,  
I would like to know the performance benefit, if any, in using array locator method as compared to other explicit iterative methods.  
Which of the below two code snippets is better in terms of performance? In general, in what cases is it recommended to use array locater method in place of usual iterative methods.

Example:  
Find the number of elements in an array that are multiples of 10.

```verilog

//#1. Code snippet using for() loop
//array_a is a large static integer array 
for(int i=0;i < array_a.size(); i++) begin 
   if( (array_a[i] % 10) == 0) cnt++;
end
$display("%0d",cnt);

//#2. Code snippet using array locator method
temp_q = array_a.find(item) with (item % 10 == 0);
$display("%0d",temp_q.size()); 	

```

Appreciate any answer.

Thank you !  
-Omkar

---

<div class="post-metadata">

**Author:** ![cgales](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/c/ccd318/32.png) [@cgales](https://verificationacademy.com/forums/u/cgales)\
**Post date:** [April 9, 2021, 10:18am UTC](https://verificationacademy.com/forums/t/performance-benefit-in-using-array-locator-method/38959/2 "2021-04-09T10:18:46Z")

</div>

_In reply to [Omkar](https://verificationacademy.com/forums/t/performance-benefit-in-using-array-locator-method/38959):_

For small data sets, there likely isn’t much difference. However, you may see better performance using the array locator methods on larger sets as these will be optimized by the tool vendor.

Also, leveraging the language features to write less code is always a good idea.
