Tuesday, August 05, 2008

Win32 vs. WPF Performance

I created two similar applications in Visual Studio 2008, one as a Windows Forms Application and the other as a WPF Application.

Windows Forms Application (Win32) WPF Application

I then preformed the following tests (ran tests three times and recorded the average) as listed below:

  • Time it takes to open one window.
  • Time it takes to open 100 windows.
  • Time it takes to open a window with many controls.
  • Amount of memory consumed after opening the application.
  • Amount of memory consumed after launching one window.
  • Amount of memory consumed after launching 100 windows.
  • Amount of memory consumed after launching a window with many controls.
  • Amount of memory consumed after launching a Win32 open dialog (only in WPF).

Note: I only tested this on a single Windows XP machine and a single Vista machine. And I am ignoring hardware configurations.
Note: Memory was recorded from the task manager.

Windows XP – Time in seconds

 

Win32

WPF

Launch Single Window

0.0233669

0.2370075

Launch 100 Windows

1.0548501

21.5009168

Controls Window

0.3838853

0.4473099

Windows XP – Memory

 

Win32

WPF

Just Application

13,345K

19,340K

Launch Single Window

13,885K

20,867K

Launch 100 Windows

15,089K

55,685K

Controls Window

16,333K

24,859K

Launch Win32 Dialog

23,440K

Vista – Time in seconds

 

Win32

WPF

Launch Single Window

0.0170000

0.913333

Launch 100 Windows

1.1940000

12.43466667

Controls Window

0.2886667

0.4900000

Vista - Memory

 

Win32

WPF

Just Application

3,623K

11,995K

Launch Single Window

3,715K

12,595K

Launch 100 Windows

4,377K

15,715K

Controls Window

6,132K

16,241K

Launch Win32 Dialog

14,132K

Results

Windows XP

  • Unless you have a lot of controls on a window, Win32 is faster. In my test of the control window Win32 was faster, however WPF was not far behind.
  • WPF can manage a lot of controls on a form better then Win32. It is hard to show in a benchmark, but by running the applications you will notice that sizing the controls window in WFP is more responsive then Win32.
  • Launch many WPF windows is slow and consumes a lot of memory.
  • When you launch a Win32 dialog from WPF there is overhead.
  • In general WPF comes at a cost in memory and performance.

Vista

  • For the most part the story is the same. WPF comes at a cost in memory and performance.
  • It seems that WPF doesn’t consume as much memory in the 100 windows test (at least on Vista machine that I tested).
  • On my Vista machine there was a noticeable difference in appearance between WPF windows and Win32 windows. The Win32 windows looked blurry and not as clean and crisp as the WPF windows. This alone may make WPF worth it. Sure it is slower and takes up more memory but it does look nicer.
Vista Images

Click the images to see them at full size.

 Win32ControlDlg

WPFControlsDlg

No comments: