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.
//#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