Post Reply 
Slight n-queens benchmark speedup for Casio fx-4000P, fx-7000G, etc.
02-29-2020, 05:00 PM
Post: #1
Slight n-queens benchmark speedup for Casio fx-4000P, fx-7000G, etc.
By making use of the automatic Ans variable, and playing a bit fast and loose with the parser, it's possible to squeeze a bit more speed out of the n-queens program for the fx-4000P, and presumably most (all?) of the models that use the same benchmark program.

Modified version:

Code:
        Mcl
        8->R
 Lbl 0  X=R=>Goto 4
        Isz X
        R->A[X]
 Lbl 1  Isz S
        X->Y
 Lbl 2  Dsz Y Deg
        Y=0=>Goto 0
        A[X]-A[Y
        Ans=0=>Goto 3
        X-Y<>Abs Ans=>Goto 2
 Lbl 3  Dsz A[X] Goto 1
        Dsz X Goto 3
 Lbl 4  S

By omitting the store into variable T, and instead letting A[X]-A[Y (omission of the final bracket is deliberate) automatically store in Ans, the execution time on my fx-4000P dropped from 00:05:57 to 00:05:41 (+/- 1 sec. margin of error on measurements). So, roughly a 4.5% reduction in execution time.

Note that you can't leave out the closing bracket for array references that are the target of a store or Dsz/Isz, so R->A[X] and Dsz A[X] can't benefit from this optimization.

Now somebody needs to go re-test the FX-6000G, FX-6300G, FX-6500G, FX-7000G, FX-7000GA, FX-7000GB, FX-7200G... Wink
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Slight n-queens benchmark speedup for Casio fx-4000P, fx-7000G, etc. - Dave Britten - 02-29-2020 05:00 PM



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