views:

35

answers:

1

Hi All,

I have an extjs grid and one of the column renderer function has a for loop which goes through an array of numbers and compares them with the value for every cell for the column in consideration. so I was thinking since the renderer already loops for each row, and now i have for loop runner for each row.

The question is should just let it run or should i change the array and user String.match() instead of for loop.

I don't have large data for now so that i could test. Which is better? any ideas?.

Thanks, Jai

A: 

If you want to benchmark a piece of code that takes too little time to get useful numbers, then run it multiple times inside a loop.

In JavaScript you can easily get the time (in milliseconds) it takes to execute a piece of code like this:

var starttime= +new Date()
//Do the task
var endtime= +new Date()
alert(endtime-starttime)

Whenever you ask a question about a specific piece of code you should provide the code along with the question, it is really hard to figure what your code does from your description.

eBusiness
Thank you. I guess I will just try to benchmark each of methods. I couldn't post the code because i work for a financial company and it is against company policy. thanks for the reply sir.
Oh, the security minded company policy. I presume it is just an extra precaution on top of real security measures like at least one full time employed expert cracker who do code review to comb out any potential dangers?
eBusiness
yes, everything runs on VM on a server and nothing on the laptops they give us. very security minded!