Guys- doesn't that depend - a lot - on how often the code is actually executed? A couple billion times a day makes it a no-brainer to do a binary search, a couple thousand times per day, perhaps just the opposite.
Paul Typos courtesy of my iPhone and my fat fingers! > On Oct 21, 2013, at 7:38 AM, Martin Truebner <[email protected]> wrote: > > As Rob has already said- YES it is worth it > > I say that too- worth it- here is my point. > > assumptions: > > 1.) every instr is one unit (yes I know this is pretty simple but ...) > > 2.) random access pattern > > ----so here we go > > a simple search is n instructions- > > a binary search is +x instructions > > for any number it needs exponent for next power of two > > so for 50 entries you need > normal 25 times your loop > binay 6 (50 ---> 64 is 2**6) > > so if your new code is 10 (=x)extra instructions (on top of 4 for n) > > you are still better off doing it binary (4*25 vs: 6*(10+4)) > > now the big question: who is willing to post code? > > -- > Martin > > Pi_cap_CPU - all you ever need around MWLC/SCRT/CMT in z/VSE > more at http://www.picapcpu.de
