I’m making a game where a lot of data has to process on the cpu side every frame, so I need to find the most efficient method. There are, let’s say, a fairly large number of possible chunks of code which need to be selected inside a loop based on certain data. Due to the extremely high number of iterations I need this to have the least overhead possible in selecting the code. The three options I see are:
- A large if/elseif statement with a chunk of code in each part
- A switch/case statement with a chunk of code in each part
- Using delegates where each chunk of code is inside a function call
Which do you think would be the fastest?