UserRPL Savage benchmarks Message #28 Posted by James M. Prange (Michigan) on 13 June 2007, 1:18 p.m., in response to message #17 by Egan Ford
Quote:
RPL (48/49/50 series):
<<
TICKS
1
1 2499 FOR I
SQ SQRT LN EXP ATAN TAN 1 +
NEXT
SWAP
TICKS SWAP  B>R 8192 /
>>
Certain things about the above caught my eye, and I decided to
"improve" on it.

In RPL, the square root command has the symbol for its name; SQRT
would be compiled as a global name, not as the square root
command.

A FOR...NEXT loop is used, but its index variable is never used,
so it would be better to use a START...NEXT loop.

The stack manipulation for the initial system time is handled a
bit clumsily, using two moves where only one move is needed.

The result is very likely to differ depending on whether the
angular mode is RAD, DEG, or GRAD, so this should be forced.
When I force a mode, I usually prefer to restore the original
mode.

For the 49 series, operations with "real numbers" are generally
faster than operations with "exact integers", so let's use real
numbers only.
For an integer value 9 through 9, the compilation of either a
real number or an exact integer is to the address of a ROM object,
so 2.5 bytes. Otherwise, real number objects are 10.5 bytes, and
exact integer objects are 5.5 bytes plus 0.5 byte per digit.

Binary integers are truncated to the current wordsize when you do
a mathematical operation on them, so a sufficiently large wordsize
should be forced.

Substituting DUP * for SQ saves a tiny bit of execution time,
although it uses 5 bytes instead of 2.5 bytes. In this case of a
loop that repeats 2499 times, I'd prefer to sacrifice the 2.5
bytes and save a little execution time.

A tiny bit of execution time can be saved by disabling last
arguments.

We want to see the result in full precision, so let's force STD
display mode and leave it in STD even after the program ends.

Regarding the timing, first off, the resolution on an RPL model is
1 "tick" (1/8192, or about 0.000122, second).
The TICKS command itself takes some time, so the apparent
execution time of operations between two TICKS commands is an
overestimation by the time that is takes to perform one TICKS
operation. This varies among the models, and in any case, timings
vary among units of the same model and even among repetitions of
the same program, and I choose to neglect this minor inaccuracy.
If you want to correct the inaccuracy, then run the program
\<< TICKS TICKS SWAP  B\>R \>>
a few times, average the result, and edit my program to subtract
this average from the result of the B\>R command.
Depending on free memory, a "garbage collection" may be needed, so
for timings, a garbage collection is usually forced first. Of
course, this doesn't guarantee that garbage collection won't be
needed anyway, but it often makes the timings more repeatable.
To free up more memory, last stack (UNDO) and last command lines
saves can be disabled, but remember to restore them to your
default modes when finished. These operations of
disabling/enabling these two modes are not programmable.

Some other modes, particularly those which affect the CAS on the
49 series, might have an effect.
The following program can be copied and pasted to a file to be
downloaded to any 48 or 49 series, but in case you prefer to key
it in, "\<<" and "\>>" represent the UserRPL program delimiters,
"\v/" represents the symbol for the square root command, and "\>"
represents the right arrow character. Don't bother keying in the
trailing "decimal points", but for the 49 series, enter this
program in "approximate" mode. Anything starting with an "@"
character through the next "@" character or the end of the line,
whichever comes first, is a comment; don't bother keying in any
comments.
%%HP: T(3)F(.);
@ "Savage benchmark" for 48 and 49 series.
@ 48 series checksum: # ECAh
@ 48 series size: 159
@ 49 series checksum: # B0C9h
@ 49 series size: 159.
\<< @
STD @ Force standard display mode.
RCLF @ Get original flags.
55. SF @ Force last arguments disabled.
64. STWS @ Force wordsize.
RAD @ Force radians mode.
MEM DROP @ Force a GC.
TICKS @ Initial system time.
1. @ Initial value.
1. 2499. @ Loop start/stop values.
START @
DUP * @ Square.
\v/ @ Square root command.
LN @
EXP @
ATAN @
TAN @
1. + @
NEXT @
TICKS @ Ending system time.
ROT @ Move initial time to level 1.
 @ Elapsed time.
B\>R @ Convert binary to real.
"Ticks" @
\>TAG @
DUP @
8192. / @ Convert ticks to seconds.
3. RND @ Round to 3 decimal places.
"Seconds" @
\>TAG @
4. ROLL STOF @ Restore original flags.
\>> @
The 28 series doesn't have a builtin TICKS commands, any tagged
object capability, its RND command works differently, and the
system flags differ from the 48/49 series, so the above program
won't work on them.
Depending on the ROM version, one of the following can be used as
a substitute for the TICKS command:
The 28C must be in HEX binary display mode for these SYSEVAL
addresses, and that's a good idea for the 28S as well.
Doublecheck that the address is correct before executing SYSEVAL;
a wrong address may very well clear the calculator's memory.
Model 28C ROM version 1BB: #123E SYSEVAL
Model 28C ROM version 1CC: #1266 SYSEVAL
Model 28S ROM version 2BB: #11CAh SYSEVAL
As far as I know, these were the only ROM versions ever released
for the 28 series.
To find the ROM version of a 28C, with the calculator's binary
display mode HEX, use #A SYSEVAL, or for a 28S, #Ah SYSEVAL also
works.
I'll use a character string to "tag" the timing values. The ":"
character isn't easily keyed in on a 28 series (unless you already
have that string stored), so I'll use "=" instead of ": ".
Instead of 3 RND, I'll use 3 FIX RND.
Last arguments disabling is forced by 31 CF.
Of course you can't transfer anything to a 28 series, but I choose
to use the same character translations as for the 48/49 series,
and what I wrote about comments also applies to the 28 series.
@ "Savage benchmark" for 28 series.
@ A 28C must be in HEX mode when this program is entered to ensure
@ that the correct address is supplied to SYSEVAL!
\<< @
STD @
RCLF @ Get original flags.
31 CF @ Force last arguments disabled.
64 STWS @ Force wordsize.
RAD @ Force radians mode.
MEM DROP @ Force a GC.
@ Uncomment the binary integer in one of the following 3 lines.
@ #123E @ @ For 28C ROM version 1BB.
@ #1266 @ @ For 28C ROM version 1CC.
@ #11CAh @ @ For 28S ROM version 2BB.
SYSEVAL @ Initial system time.
1 @ Initial value.
1 2499 @ Loop start/stop values.
START @
DUP * @ Square.
\v/ @ Square root command.
LN @
EXP @
ATAN @
TAN @
1 + @
NEXT @
@ Uncomment the binary integer in one of the following 3 lines.
@ #123E @ @ For 28C ROM version 1BB.
@ #1266 @ @ For 28C ROM version 1CC.
@ #11CAh @ @ For 28S ROM version 2BB.
SYSEVAL @ Ending system time.
ROT @ Move initial time to level 1.
 @ Elapsed time.
B\>R @ Convert binary to real.
DUP @
\>STR @ Convert real to character string.
"Ticks=" @
SWAP + @
SWAP @
8192 / @ Convert ticks to seconds.
3 FIX RND @ Round to 3 decimal places.
\>STR @ Convert real to character string.
"Seconds=" @
SWAP + @
4 ROLL STOF @ Restore original flags.
\>> @
All of the RPL models always return the value 2499.99948647 for
the above programs.
My timings, with 10 trials for each model, and with last stack and
last command lines disabled:
28C ROM version 1BB:
3262515 ticks, about 398.3 seconds
3262691 ticks, about 398.3 seconds
3262709 ticks, about 398.3 seconds
3262844 ticks, about 398.3 seconds
3263670 ticks, about 398.4 seconds
3263995 ticks, about 398.4 seconds
3263320 ticks, about 398.4 seconds
3263287 ticks, about 398.4 seconds
3263403 ticks, about 398.4 seconds
3263472 ticks, about 398.4 seconds
Average: 3263190.6 ticks, about 398.3 seconds
Range: 957 ticks, about 0.1168 second
28S ROM version 2BB:
2059531 ticks, about 251.4 seconds
2059943 ticks, about 251.5 seconds
2059854 ticks, about 251.4 seconds
2059888 ticks, about 251.5 seconds
2060079 ticks, about 251.5 seconds
2059892 ticks, about 251.5 seconds
2059946 ticks, about 251.5 seconds
2059652 ticks, about 251.4 seconds
2059838 ticks, about 251.4 seconds
2059848 ticks, about 251.4 seconds
Average: 2059847.1 ticks, about 251.4 seconds
Range: 548 ticks, about 0.06689 second
48SX ROM version E:
1585355 ticks, about 193.5 seconds
1585471 ticks, about 193.5 seconds
1585443 ticks, about 193.5 seconds
1585356 ticks, about 193.5 seconds
1585231 ticks, about 193.5 seconds
1585243 ticks, about 193.5 seconds
1585301 ticks, about 193.5 seconds
1585304 ticks, about 193.5 seconds
1585069 ticks, about 193.5 seconds
1585327 ticks, about 193.5 seconds
Average: 1585310 ticks, about 193.5 seconds
Range: 402 ticks, about 0.04907 second
48GX ROM version R:
968311 ticks, about 118.2 seconds
969964 ticks, about 118.4 seconds
970312 ticks, about 118.4 seconds
970479 ticks, about 118.5 seconds
970334 ticks, about 118.4 seconds
970284 ticks, about 118.4 seconds
969569 ticks, about 118.4 seconds
969730 ticks, about 118.4 seconds
968488 ticks, about 118.2 seconds
967720 ticks, about 118.1 seconds
Average: 969519.1 ticks, about 118.3 seconds
Range: 2759 ticks, about 0.3368 second
49G ROM Version G Revision 2.107:
915388 ticks, about 111.7 seconds
915136 ticks, about 111.7 seconds
915163 ticks, about 111.7 seconds
915501 ticks, about 111.8 seconds
915477 ticks, about 111.8 seconds
915516 ticks, about 111.8 seconds
915231 ticks, about 111.7 seconds
915535 ticks, about 111.8 seconds
915502 ticks, about 111.8 seconds
915490 ticks, about 111.8 seconds
Average: 915393.9 ticks, about 111.7 seconds
Range: 399 ticks, about 0.04871 second
49g+ ROM Version G Revision 2.107:
523531 ticks, about 63.91 seconds
523570 ticks, about 63.91 seconds
523624 ticks, about 63.92 seconds
523580 ticks, about 63.91 seconds
523575 ticks, about 63.91 seconds
523546 ticks, about 63.91 seconds
523545 ticks, about 63.91 seconds
523564 ticks, about 63.91 seconds
523539 ticks, about 63.91 seconds
523511 ticks, about 63.91 seconds
Average: 523558.5 ticks, about 63.91 seconds
Range: 113 ticks, about 0.01379 second
50g ROM Version G Revision 2.107:
526730 ticks, about 64.30 seconds
526688 ticks, about 64.30 seconds
526721 ticks, about 64.30 seconds
526714 ticks, about 64.30 seconds
526572 ticks, about 64.28 seconds
526757 ticks, about 64.30 seconds
526696 ticks, about 64.29 seconds
526681 ticks, about 64.29 seconds
526806 ticks, about 64.31 seconds
526698 ticks, about 64.29 seconds
Average: 526706.3 ticks, about 64.30 seconds
Range: 234 ticks, about 0.02856 second
Regards, James
