On 24.05.2007 00:15, Stefan Rusterholz wrote: > Mike Steiner wrote: >> I ran the profiler on my program and it said that 51% of the time is >> spent >> in Array#each. Is there any way to speed this up (like using >> Array#each_index perhaps)? Note that the profiler output is often irritating because time for each also includes all the time spend in the block - and while #each is invoked only once the block is invoked n times. >> And is there a quicker way to do a .gsub if I'm using just strings and >> not a regexp? Quicker than what? Are you using the block form of gsub? Are you using gsub! or gsub? Can you show some code? >> By the way, the program compares 2 databases and determines which >> records >> have been inserted and deleted, and each database has about 15,000 >> records >> to compare. 15,000 does not sound like much. What is the runtime of the program without profile? And another idea: could be that you are using inefficient methods to test for existence. Finding something in an Array is always O(n) unless you have additional constraints; i.e. array content is sorted in which case you can use binary search which is O(log(n)). It seems you want to be doing set operations - so why don't you try to use Set for which member tests are far more efficient (O(1) because it's using hashing internally). Kind regards robert