Jano Svitok
3/17/2008 4:51:00 PM
On Mon, Mar 17, 2008 at 1:42 PM, Marc Heiler <shevegen@linuxmail.org> wrote:
> Anyone of you has a few hints on how to speed up ruby code?
> (Note - not writing it, but running it ;-) )
> If you know a few more hints, please add!
ParseDate#parsedate is expensive - it uses rationals, gcd and other
heavy stuff to convert from [D, M, Y, H, M, S] to timestamp.
Once we did a log merger and we ordered the entries by time. We saved
a lot of processing time by storing the timestamps in the logs along
with the formatted date.
(They were removed afterwards during formatting.)
ERB#new is expensive. Cache compiled templates if they are to be reused.
Use /o switch for Regexp literals that contain constant
#{substitutions} (i.e. that do not depend on function parameters)