In WP7 the game developers worry about the CPU and the GPU for the performance and that managed code does not performed as unmanaged code. Game developer like C++ and they are very good at optimizing that code. Now Microsoft tells them to use C#.
Why to use C#
- Powerful and expressive
- Type safety reduces hard to track down bugs
- Initialize syntax
- Blazingly fast compilers
- Similar enough to C.
What CPU has Windows Phone 7? ARMv7 CPU
Speed of calling code in order of fastest to slowest
- Instance Method
- Virtual Method
- Delegate Event
In .NET you cannot turn the Garbage Collector off. What does it do when you call GC.Collect();
- Triggered per megabyte of allocation
- Starts with root references
- Recursively follows all references to see what other objects can be reached
- Anything we didn’t reach must be garbage
Keeping the GC happy, make it run less often by use object pools or make it finish quickly by using simple heap.
Tips to improve performance:
- Beware of boxing
- Use StringBuilder instead of string
- Use WeakReference to track GC frequency
The GPU in the phone is very powerful you can run all this effects
- Basic Effect
- Dual Texture Effect
- Alpha Test Effect
- Skinned Effect
- Environment Map Effect
You need to be balancing
- Frame rate, it refreshes at 30hz, no point updating faster than that.
- Pixel cost, prefers cheaper effects, minimize overdraw, draw untextured with additive blending.
- Number of pixels, 800x480 is you drop it to 600x360 you saving 56% of the pixels.
Hope that helps!
Follow me at twitter @alpascual