It sounds as though you are comparing wall clock run times. Check the load at the time the program is run. I have seen similar behavior lots of times. Is it possible that the data is in cache sometimes and other times has to be read from disk?
Benchmarking is tricky. Your example does a good job of showing how factors other than code structure can impact performance.
HTH, --traveler
Comment on Re: Same code, same data, different execution times?