RevEng Posted June 27, 2009 Share Posted June 27, 2009 (edited) I was curious to see how many cycles certain operations took in bB, so I ran a bunch of loop for each operation and subtracted from the cyclecount. (also subtracting the loop overhead) The result was fairly educational. I anticipated many of the results, but perhaps not to the magnitude I discovered. It's certainly helped me in my game tuning, so hopefully someone else finds use for it. No doubt some assembly coders are going to suggest that I could have just added up cycles in the assembly. That get's pretty hairy when you're going though long branching code, and this method IMO was good enough to get a good idea of what the piggie operations are. The results... a=b+c : 11.5 cycles (+-1.3 cycles) a=b/3 : 460.8 cycles (+-12.8 cycles) a=b/2 : 7.68 cycles (+-1.3 cycles) * a.a=b.b+c.c : 11.52 cycles (+-1.3 cycles) a.d=b.b+c.c : 11.52 cycles (+-1.3 cycles) a.d=b.b+c.f : 11.52 cycles (+-1.3 cycles) a.d=b.e+c.c : 160.0 cycles (+-6.4 cycles) ** a.d=b.e+c.f : 20.48 cycles (+-1.3 cycles) gosub+return : 25.6 cycles (+-1.3 cycles) gosub_with_bankswitch+return : 123.73 cycles (+-4.2 cycles) goto: 2.56 cycles (+-1.28) *** goto_with_bankswitch : 49.06 cycles (+-4.2) -------------------------------------------------- * = x/2 is a lot less than x/3 because bB uses a rotate-rights for divisions by powers of 2. ** = this one is weird. If you add an 8.8 type and a 4.4 type, it's *way* slow if the 8.8 is first. *** = bB implements this with a jmp, which is 3 cycles. This one was a check of my methods. Note 1: a,b,c=byte a.a,b.b,c.c=bB 4.4 fp type a.d,b.e,c.f=bB 8.8 fp type Note 2: an empty-loop in the bB standard kernel has about ~2432 spare cycles. (~3432 if you count vblank area) an empty-loop in the bB multi-sprite kernel has about ~2176 spare cycles. (not much more in the vblank) Edited June 27, 2009 by RevEng Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.