Programming Exercise (HP-15C, 15C LE - and others)
|
04-01-2014, 07:37 PM
Post: #80
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
(04-01-2014 09:17 AM)HP67 Wrote: From your description of null-named locals it would seem the stack version should still be faster, all else being equal. I'm surprised over 10,000 iterations it didn't have more impact. Looking at the two versions, the stack version of the loop actually has fewer steps. So I also thought that the stack version would be faster when I first coded it. But the most time-consuming operations in the loop are the computations, not the stack manipulations. Moving pointers around is practically inconsequential when compared to the time involved to compute the inverse of an extended real BCD value (or the sum or product, etc.). The most time-hungry parts of the two loops are exactly the same (-,*,1/x,+,-). That's why the timings are so close; the two versions spend the bulk of their time doing essentially the same steps. To check my sanity, I did some more testing of these two versions. I created another code object which ran both versions (one after the other) in a loop of 20 iterations. On an emulated 50g (Emu48 1.53+), the stack-based version was faster than the local vars version on 18 of 20 iterations. When I ran the exact same test on my real 50g, the local vars version was faster 16 of 20. In both tests, the differences were minor. To me, that means that the two versions are so close in speed that other idiosyncrasies of the system (intermittent garbage collection, nibble-alignment, interrupt handling, clock irregularities, etc.) are what's making the difference between the two. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 10 Guest(s)