>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. >Benchmark: running s, tr, each for at least 3 CPU seconds... > s: 4 wallclock secs ( 3.04 usr + 0.00 sys = 3.04 CPU) @ >40420.72/s (n=122879) > tr: 5 wallclock secs ( 2.99 usr + 0.01 sys = 3.00 CPU) @ >156540.00/s (n=469620) > >And with longer strings, the difference is even more significant. this would also hold true for the time required to obtain a result from algorithms using either of these :-) At 2:37 PM +0200 21/07/01, Detlef Lindenthal wrote: >Here is OMWTDI, "matching" instead of "replacing": > $_ = "abc" x 10; > while (m,a,g) { $x++ }; > print "Letter 'a' was found $x times"; >And seamingly it is not slow. Put your benchmarks where your mouth is ;-)