Why the same code in WPF is slower than in Windows Forms?
- by Marco Bettiolo
I made bunch of benchmarks of the framework 4.0 and older and I can't understand why the same code is slower when using WPF compared to Windows Forms:
This is the code, it has nothing to do with the UI elements:
Random rnd = new Random(845038);
Int64 number = 0;
for (int i = 0; i < 500000000; i++)
{
number += rnd.Next();
}
The code takes 5968ms - 6024ms to execute in Windows Forms and 6953ms in WPF.
Here is the post with the downloadable solution: http://blog.bettiolo.it/2010/04/benchmark-of-net-framework-40.html