making my program faster...

Programming, for all ages and all languages.
Ready4Dis
Member
Member
Posts: 571
Joined: Sat Nov 18, 2006 9:11 am

Post 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.
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Post by earlz »

hmmm well for 8086 opcodes I don't have to worry much about segments or code checks of that sort but anyway........
Post Reply