No such thing as a small change | |
PerlMonks |
Re^4: Display shortened paragraphby blazar (Canon) |
on Feb 02, 2006 at 10:00 UTC ( [id://527280]=note: print w/replies, xml ) | Need Help?? |
The benchmark should strongly convey that dealing retail with characters is SLOW (jbrug2) and that narrow purpose functions (substr, rindex) are faster than general purpose functions (regex). That is a valuable lesson in any book! (Forgive me for the sarcasm but...) Whoa! I would have never expected, without running a benchmark!! In particular jbrug2 is
Be sincere: do you really need a benchmark to have an idea of the performance merits of code that basically does a perl reimplementation of substr by using a C-style for loop to append entries of an array to a variable one at a time? Whatever, what I'm contending is that while a valuation of relative merits in terms of performance may have some relevance in other cases, it has none for this task. The OP is asking for a method to display some text a chunk at a time, to ease reading. What is the point of searching for the maximum speed of execution when any solution, including jbrug2, is well beyond the limits of human perception? Personally I think that there are (by far) more important/interesting aspects to take care of. For example your benchmark compares some approaches to take (about) the first 255 charachters of a string. How do they scale if the requirement is added to take successive chunks? What if the string is less than 255 charachters? These are points to be discussed. But your post claims "and the best answer is: [benchmark]" FWIW add this beautiful creation of mine to the benchmark, if you like:
In Section
Seekers of Perl Wisdom
|
|