On Mon, Jul 23, 2001 at 09:39:57PM +0900, [EMAIL PROTECTED] wrote:
> >On Sat, Jul 21, 2001 at 01:16:04PM +0900, [EMAIL PROTECTED] wrote:
> >
> > > tr/// is slightly more efficient than s///,
>
>
> At 7:55 AM -0400 21/07/01, Ronald J Kimball wrote:
> >I think you underestimate the efficiency of tr/// for counting characters
> >:)
>
> By efficient I intended the speed at which the result is gained. I
> also use 'efficient' in this sense to describe the response time of
> my local fire service - you intend in the number of iterations
> required to get the result, which put into the fire service anology
> means your talking about an 'as the crow flies' fuel consumption of
> the response vehicle, compared to the actual fuel consumption.
I'm afraid I cannot figure out what that paragraph is trying to say.
In 1 second, the tr/// solution counted the occurences of the character 'a'
469,620 times. In the same amount of time, the s///g solution counted the
occurences only 122,879 times. In other words, for a string of 30
characters, tr/a// is something like four times faster than s/a/a/g.
Further, with a string of 300 characters (change C<'abc' x 10> to C<'abc' x
100>, tr/a// was about 100 times faster than s/a/a/g.
Ronald