in reply to Re: Performance Question
in thread Performance Question

++ to you for more tries at solutions.

The thing that isn't stated by the OP is how large the templates are. If the string is relatively short then doing the multiple regex passes is fine. The longer the template becomes - if he wants it to be fast - he really needs to try and get the number of passes as low as he can.

The final question is - is this swapping bit the bottle neck of the process. If the OP is running these as CGI processes - then it probably doesn't matter what algorithm he is using because the startup time of the CGI is going to be costly -- that is unless the templates being used are mega bytes in size.

my @a=qw(random brilliant braindead); print $a[rand(@a)];

Replies are listed 'Best First'.
Re^3: Performance Question
by agianni (Hermit) on Feb 28, 2007 at 17:56 UTC
    Right, I actually just updated my post (not sure if you read it before or after) but the point is that this alternate algorithm won't save you much with a small number of variables and a small file and could actually cost you more for very small numbers, like any sized file with no variables defined.
      Right, I actually just updated my post (not sure if you read it before or after)

      But I don't see any indication in your post of you having done so. It is a common and recommended practice here not to silently update posts, except for typos or minor things that is, but to mark updates with visually distinctive "tags": otherwise replies may even cease to make sense, and the overall quality of the discussion may risk to be lowered.