Talk:Ordered words: Difference between revisions

m (→‎A bug (which was not really a bug) in Rexx solution: removed trailing blank line from the one-line subroutine. -- ~~~~)
Line 162:
</lang>
--[[User:Walterpachl|Walterpachl]] 19:26, 15 July 2012 (UTC)
 
The above REXX program could be shortened to:
<lang rexx>uppercase: Procedure
a=translate(arg(1),'ÄÖÜ',"äöü") /* translate lowercase umlaute */
a=changestr("ß",a,'SS') /* replace ß with SS */
return translate(a) /* translate lowercase letters */</lang>
(which removes a line of dead code.)
 
<br>As for using '''Procedure''', it does come with some overhead.
<br>I ran a benchmark with the original '''uppercase''' subroutine, and the second version, along with the above version and the one-liner version.
 
The original version was faster than version two (but only slightly), and the one-liner was about four times faster. An in-line version was twice as fast as the one-liner.
 
Now, in this day and age of fast computers, some people don't care about speed that much. I have two REXX applications, one that processes over 708,000 records (actually, words in an English word list which needs to be uppercased while doing a search), and that amount of invocations addes up. Another application reads over 58 million records, and one can see that inefficient subroutines can really slow up the works. I'd like to think that Rosetta Code is a place to show well-written routines that are applicable to any size/amount of use; one can never know where people will use such a routine (or the scale of use). A REXX ''procedure'' has to build an environment which has its own NUMERIC DIGITS, FORM, and FUZZ, its own timing (elapsed and resetted timers), local REXX variables (RC, SIGL, RESULT), and whatnot. In the above case, one local variable ('''a''') also has to be DROPed. There is always something to be paid (as far as overhead). Once the '''uppercase''' becomes a one-liner, then it becomes available to be used as an in-line algorithm, bypassing the overhead of calling a subroutine (whether a procedure or not). If anyone wants to see the benchmark REXX program, I can post it here. -- [[User:Gerard Schildberger|Gerard Schildberger]] 02:04, 16 July 2012 (UTC)