Talk:Ordered words: Difference between revisions
Content added Content deleted
Walterpachl (talk | contribs) (→A bug (which was not really a bug) in Rexx solution: Procedure performance) |
(→A bug (which was not really a bug) in Rexx solution: added additional benchmarking results (and it's REXX program). -- ~~~~) |
||
Line 191: | Line 191: | ||
:which is actually avoiding empty lines created by the formatter and |
:which is actually avoiding empty lines created by the formatter and |
||
:makes copy/paste harder for me. |
:makes copy/paste harder for me. |
||
:: No, I was referring to dead '''code''', not whitespace. The code that I was referring to was the '''Parse Arg a''' REXX statement, which I see is no longer present in the above example, but it is back in the benchmark program. -- [[User:Gerard Schildberger|Gerard Schildberger]] 20:53, 16 July 2012 (UTC) |
|||
:: By the way, the above boxed REXX example for the '''uppercase''' subroutine/function is the best yet, a straight one-liner, albeit that it's really a two-liner. -- [[User:Gerard Schildberger|Gerard Schildberger]] 20:53, 16 July 2012 (UTC) |
|||
And finally, can you provide your benchmark results for the strict comparison case? |
And finally, can you provide your benchmark results for the strict comparison case? |
||
::--[[User:Walterpachl|Walterpachl]] 06:11, 16 July 2012 (UTC) |
::--[[User:Walterpachl|Walterpachl]] 06:11, 16 July 2012 (UTC) |
||
Line 219: | Line 224: | ||
:please post your benchmark |
:please post your benchmark |
||
--[[User:Walterpachl|Walterpachl]] 06:45, 16 July 2012 (UTC) |
--[[User:Walterpachl|Walterpachl]] 06:45, 16 July 2012 (UTC) |
||
----- |
|||
I can't speak for ooRexx as I don't have a copy to test it. |
|||
I don't like to use words like ''mere'' which preloads a judgement. |
|||
30% of an 20 hour run is an extra ¼ day (this would be in regards to that 82 million record "database"). |
|||
I took your program as is and ran it on my isolated computer (no internet connection, no active anti-virus protection programs running, etc, it's a 3.20 GHz box and is running all four processors with five 100%-CPU-bound unrelated programs on below-normal priority), and the results are: |
|||
oneliner: 10000001 13.088000 |
|||
Procedure: 10000001 60.223000 |
|||
Then, just to show what the REXX overhead is for processing a "normal" '''do''' loop, I replaced the |
|||
<lang rexx>do i=1 to 10000000</lang> |
|||
with |
|||
<lang rexx>i=10000000 |
|||
do i</lang> |
|||
and the results are: |
|||
oneliner: 10000001 13.412000 |
|||
Procedure: 10000001 60.061000 |
|||
Considering that the bulk of the execution time is spent in the subroutines, it's noteworthy; the difference is the way REXX handles incrementing a '''do''' loop index (and testing for termination of same). |
|||
<br>I then made the program compliant by adding a |
|||
<lang>/*REXX*/</lang> |
|||
statement to the front of the program. |
|||
<br>Code was then added for: |
|||
* user-specifiable (number of) times to repeat the loop |
|||
* added "greasers" (have REXX allocate stuff so SUBs don't have to) |
|||
* force REXX interpreter to read entire file (mostly for older REXXes) |
|||
* a repetition of both invocations to eliminate snowplowing |
|||
* use of FOR instead of TO in DO loops for faster execution |
|||
* disallowing the cacheing effect for "small" loops |
|||
* made invocations unique by using unique passed arguments |
|||
* eliminating piggy-backing by not using the same variables |
|||
* show the version of the REXX interpreter |
|||
<br>Here's the code that was used for the 3rd benchmark: |
|||
<lang rexx>/*REXX*/ parse version _; say 'version:' _; say |
|||
arg times . |
|||
if times=='' then times=10 * 1000000 /*ten million times, yikes ! */ |
|||
call time 'R' /*just grease the wheels a bit*/ |
|||
call uppercase; call uppercase2 /*force some REXXes to get 'em*/ |
|||
x=0; y=0; j=0; k=0 /*have REXX allocate variables*/ |
|||
do 2 |
|||
call time 'R' /*────────────────────reset the REXX timer*/ |
|||
do j=1 for times |
|||
x=uppercase(j 'w÷lter') |
|||
end |
|||
say 'oneliner: ' j time('e') |
|||
call time 'R' /*────────────────────reset the REXX timer*/ |
|||
do k=1 for times |
|||
y=uppercase2(k 'w÷lter') |
|||
end |
|||
say 'procedure:' k time('e') |
|||
end |
|||
exit |
|||
/*──────────────────────────────────UPPERCASE subroutine─────────────*/ |
|||
uppercase: |
|||
return translate(changestr("ß",translate(arg(1),'ÄÖÜ',"äöü"),'SS')) |
|||
/*──────────────────────────────────UPPERCASE2 subroutine────────────*/ |
|||
uppercase2: procedure |
|||
parse arg a |
|||
a=translate(arg(1),'ÄÖÜ',"äöü") /* translate lowercase umlaute */ |
|||
a=changestr("ß",a,'SS') /* replace ß with SS */ |
|||
return translate(a) /* translate lowercase letters */</lang> |
|||
and the results were: |
|||
version: REXX-Regina_3.6(MT) 5.00 31 Dec 2011 |
|||
oneliner: 10000001 15.605000 |
|||
Procedure: 10000001 63.023000 |
|||
oneliner: 10000001 15.420000 |
|||
Procedure: 10000001 63.106000 |
|||
<br>More work should be done on the benchmark REXX program(s), but there's only so much time in a day... -- [[User:Gerard Schildberger|Gerard Schildberger]] 20:53, 16 July 2012 (UTC) |