May
30
Performance and scalability cheatsheet
Performance tips!
Boxing and unboxing cost might be high especially when in a loop (can create many heap allocations).
Tail recursion If you find yourself in a situation where you are doing a recursive call (where you should first find for already existing library function to do the operation for you instead of recursive call), then do whatever possible for the recursive call to be tail recursive. A function is tail recursive if the recursive call is the last instruction performed which means only first call is in stack. A hint for many tail recursive call is that you pass some accumulator inside the recursive call, which means you are doing the calculation in the next step in the recursion as opposed to holding the accumulator outside the tail recursive call.
Boxing and unboxing cost might be high especially when in a loop (can create many heap allocations).
Tail recursion If you find yourself in a situation where you are doing a recursive call (where you should first find for already existing library function to do the operation for you instead of recursive call), then do whatever possible for the recursive call to be tail recursive. A function is tail recursive if the recursive call is the last instruction performed which means only first call is in stack. A hint for many tail recursive call is that you pass some accumulator inside the recursive call, which means you are doing the calculation in the next step in the recursion as opposed to holding the accumulator outside the tail recursive call.