Talk:Ordered words: Difference between revisions

m (→‎A bug (which was not really a bug) in Rexx solution: added a REXX comment showing the ''dead'' code. -- ~~~~)
Line 309:
</pre>
<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)
 
== added REXX benchmarks for = vs == comparisons. -- [[User:Gerard Schildberger|Gerard Schildberger]] 23:32, 16 July 2012 (UTC) ==
 
==REXX benchmarks==
 
These are the results for REXX exact vs. regular comparisons as per Walter's request.
 
<br>I no longer have the original ''regular compare'' vs. ''exact compare'' REXX benchmarking programs,
<br>but I took the (above) existing code and ripped its guts out (er, disembowelled it), and made a
<br>simple benchmark test out of it.
 
I soon discovered that the two versions of the '''if''' statement was being drawfed by the
<br>overhead of the '''do''' loop, so I unrolled the '''if''' statements.
 
Just for grins, I reversed the order of the compares on every other compare, and I was
<br>somewhat surprised that more CPU time was consummed.
<br>I left that modification in the benchmark program.
 
I ran the REXX benchmark against the three classic REXX interpreters that I have
<br>installed on my two computers, plus an o-o REXX interpreter:
 
* R4
* ROO
* Regina
* Personnal REXX
 
<lang rexx>/*REXX*/ parse version _; say 'version:' _; say
arg times .
if times=='' then times=1000000 /*default is one-million times*/
call time 'R' /*just grease the wheels a bit*/
j=0; k=0; x=0; y=0 /*have REXX allocate variables*/
 
do 3
call time 'R' /*────────────────────reset the REXX timer*/
do j=1 for times
if _=j then x=j
if j=_ then x=j
if _=j then x=j
if j=_ then x=j
if _=j then x=j
if j=_ then x=j
if _=j then x=j
if j=_ then x=j
if _=j then x=j
if j=_ then x=j
if _=j then x=j
if j=_ then x=j
end
say ' reg compare:' times "times" right(format(time('e'),,2),15)
 
call time 'R' /*────────────────────reset the REXX timer*/
do k=1 for times
if _==k then y=k
if k==_ then y=k
if _==k then y=k
if k==_ then y=k
if _==k then y=k
if k==_ then y=k
if _==k then y=k
if k==_ then y=k
if _==k then y=k
if k==_ then y=k
if _==k then y=k
if k==_ then y=k
end
say 'Xact compare:' times "times" right(format(time('e'),,2),15)
say
end</lang>
Using the benchmark program (shown above), for both computers (one is running
<br>Windows/XP pro, the other is running Windows 7), the results are:
<pre>
* R4 --------------- 27% slower using regular comparisons
* ROO -------------- 39% slower using regular comparisons
* Regina ----------- 150% slower using regular comparisons
* Personnal REXX --- 250% slower using regular comparisons
</pre>
<br>(In all of the above runs (about a half-dozen runs on each computer), I used the
<br>lowest percentage found.)
<lang rexx>/*REXX*/ parse version _; say 'version:' _; say; _=word(_,2)
arg times .
if times=='' then times=1000000 /*default is one-million times*/
call time 'R' /*just grease the wheels a bit*/
j=0; k=0; x=0; y=0; p=0; q=0 /*have REXX allocate variables*/
 
do 3
call time 'R' /*────────────────────reset the REXX timer*/
do j=1 for times
p=_||j
if p=j then x=j
if j=p then x=j
end
say ' reg compare:' times "times" right(format(time('e'),,2),15)
 
call time 'R' /*────────────────────reset the REXX timer*/
do k=1 for times
q=_||j
if q==k then y=k
if k==q then y=k
end
say 'Xact compare:' times "times" right(format(time('e'),,2),15)
say
end</lang>
Using the benchmark program (shown above) and using the same methodology, the results are:
<pre>
* R4 --------------- 115% slower using regular comparisons (115% --> 119%)
* ROO -------------- 39% slower using regular comparisons (39% --> 40%)
* Regina ----------- 40% slower using regular comparisons (40% --> 41%)
* Personnal REXX --- 35% slower using regular comparisons (35% --> 41%)
</pre>
<br>(In all of the above runs (again, about a half-dozen runs), I used the lowest percentage found, but I
included the ranges as well.)
<br><br>Please note that these benchmark tests were of the "quick and dirty" type, and I didn't have the
<br>time to spend on it as I would have wished. I spent (probably) way too much time on this simple case.
<br>As with most benchmarks, I often feel that I'm leading a horse to water ...
<br> -- [[User:Gerard Schildberger|Gerard Schildberger]] 23:32, 16 July 2012 (UTC)
 
-----