Post Reply 
50g Mini-Challenge: Number of positive divisors of x!
09-30-2017, 10:52 PM
Post: #13
RE: 50g Mini-Challenge: Number of positive divisors of x!
(09-30-2017 08:17 PM)Joe Horn Wrote:  (2) Your second System RPL program evaluates an input of 100 in half a second, so when I keyed up the same program in User RPL (exactly the same, step-by-step, just in URPL), I expected it to run slower, but it ran MUCH slower than I anticipated. URPL is always slower than SysRPL, but this difference seems crazy:

320 SysRPL --> 1.5 seconds
320 URPL --> 18.6 seconds!

Why is this SysRPL program so much faster? Is it simply because SysRPL is always faster, especially when looping is involved?

In addition to the inherent loop structure speedup that SysRPL gives, I think if you look at what's inside those loops you'll see another reason for the speed advantage that Gerald's SysRPL version has: lots of "combo" commands that directly manipulate the stack without having to validate the arguments given. 5ROLL, 4UNROLL, 2DROP, etc. go about their business without bothering to check that the stack can accommodate their action or that the numeric constant applies. So in many of the "equivalent" UserRPL steps, you've not only got the usual overhead for argument count/type checking (and LASTARG/cached stack saving), you've also got additional RPL stream maintenance and stack validation occurring that aren't present when executing the SysRPL code.

Those combo commands for manipulating the stack can be a pain to remember in SysRPL but they really pay off sometimes in inner loops.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: 50g Mini-Challenge: Number of positive divisors of x! - DavidM - 09-30-2017 10:52 PM



User(s) browsing this thread: 1 Guest(s)