From: Ryan Leavengood Date: 2005-11-04T06:44:20+09:00 Subject: Re: Ruby Performance vs. Java On 11/3/05, Ryan Leavengood wrote: > > Also, I would suspect that Mr. Kumar's Ruby code could benefit from > some tweaking by the experts on this list. Recent threads have shown > that smarter algorithms can make Ruby code much, much faster. In my > opinion his run against his log files seems absurdly slow. To respond to myself, it seems the main culprit is Mr. Kumar's LogEntry class, whose source code can be gotten here: http://www.pankaj-k.net/archives/ruby_java/logentry.rb I've done some benchmarking and the biggest CPU hog is the call to DateTime.strptime. By changing that call to just DateTime.new (arguably removing some functionality from the class), the runtime performance of 10,000 iterations of calling LogEntry.new goes from 24.18 seconds to 7.39 seconds, on my laptop (P4 2.8 GHz, 1 GB RAM, Windows XP, similar to his test system.) I believe his regular expressions could be improved as well. Anyone up to the challenge of making this LogEntry class much faster? Ryan