Why is the same code slower in WPF than in Windows Forms?

I have created many tests for platform 4.0 and older, and I don’t understand why the same code works slower when using WPF compared to Windows Forms:

This is code, it has nothing to do with user interface elements:

        Random rnd = new Random(845038);
        Int64 number = 0;
        for (int i = 0; i < 500000000; i++)
        {
            number += rnd.Next();
        }

In WPF, the code accepts 5968ms - 6024ms for Windows Forms and 6953ms in WPF.

Here is a post with a downloadable solution: http://blog.bettiolo.it/2010/04/benchmark-of-net-framework-40.html

+3
source share
5 answers

When I downloaded the zip file and looked at your code, the problem became obvious: This is not the same code.

, - # JIT-. . . .

, :

  • (9 7)
  • Application.DoEvents(),

, WinForms JIT- "i" , WPF , .

, WPF WinForms: , , , -.

. , , .

+1

Windows . , , WPF, ( ), , Winforms.

+3

.

?

+3

, - , 24-48 . -, . - gui-gode , , ergo, .

, , , , . WPF Winforms .

, . , WPF , , WPF.

, , , . , , .

, WPF, , .

+2

Do you have any form showing on screen? I think the overhead for the form may be what you see.

+1
source

Source: https://habr.com/ru/post/1740926/


All Articles