Page 2 of 2

Posted: Sat Nov 25, 2006 2:44 am
by Ready4Dis
Well, here was a test done by me for this exact reason, it was in '03, and compiled under msvc 6 (also others compiled it under gcc/linux for comparison), and the same kept happening, the switch statement was the fastest method, because it got converted to a jump table by the compiler. I actually wrote a version where I hacked my own jump table, but it wasn't really any faster. Check it out:

http://ready4dis.8m.com/gdev_vm.zip

It runs 3 methods multiple times (so the first doesn't get screwed by the cache). Feel free to play with it, of course your instruction set will be different, but hey ;). The methods are as follows: function call table, switch statement and switch statement with inlined functions.

Posted: Fri Dec 08, 2006 8:54 pm
by earlz
hmmm well for 8086 opcodes I don't have to worry much about segments or code checks of that sort but anyway........