88Pro Thinking

cat /senthoor/mind | grep thought > blog

Wednesday, May 26, 2004

Did you know?: Java Performance

I was not productive at work at all yesterday. I was kind of reckless and most of the time while I was on my seat; I was just typing different URLs and checking whether there are any updated information on any of those sites. I didn’t realize what I was doing and why I was acting like that, however when I went home also it continued, but not with sites, but with books. I went through some chapters of Rapid Developmentand didn’t find anything interesting since the chapters I went through were already covered in the book Peoplewear. Then I saw Java Performance Tuning lying on the shelf and thought I will just browse. Then I stumbled across something interesting. Here is the extract:

Don’t Terminate Loops with Method Calls

Avoid using method call in a loop termination test; the over head is significant. I often see loops like this when iterating through collections such as Vectors and Strings:

for (int i=0; i < collection.size(); i++) // or collection.length()

This next loop factors out the maximum iteration value and is faster:

int max = v.size(); // or int max = s.length()
for(int i = 0; i < max; i++)

Once I read I experienced some peace of mind within myself. Then it struck me why I was reckless. Early in the day since I was hoping to learn something new for the day and when I didn’t learn anything new, my mind was trying all different websites in search for some piece of knowledge which I didn’t posses already. Once I found something new, I was back to my senses.

I think this is bad for me. Just because I couldn’t learn something new, I can’t stop being productive. I have to learn to let it go sometimes.

posted by 88Pro / Wednesday, May 26, 2004

This page is powered by Blogger. Isn't yours?

doteasy.com - free web hosting. Free hosting with no banners.