Tech Tock

Time is of the essence.

Quick and Dirty WPF Performance Tester

Here’s a quick way to test WPF performance.  Set some dummy data, then log the the next time the UI thread is available via a Dispatcher.BeginInvoke.  This is a good way to show virtualization is working.  If you need more than this you’re either in high performance land or trouble.

WPF Tester
  1. publicclassViewModel
  2. {
  3.     int_timeTaken;
  4.     publicintWpfTimeTaken
  5.     {
  6.         get { return_timeTaken; }
  7.         set
  8.         {
  9.             CheckPropertyChanged(“WpfTimeTaken”, ref_timeTaken, refvalue);
  10.         }
  11.     }
  12.     privatevoidGenerateData()
  13.     {
  14.         //set data
  15.         varsw = newSystem.Diagnostics.Stopwatch();
  16.         Dispatcher.CurrentDispatcher.BeginInvoke(
  17.             newAction(() =>
  18.             {
  19.                 this.WpfTimeTaken = sw.ElapsedMilliseconds;       
  20.             }), System.Windows.Threading.DispatcherPriority.ApplicationIdle);
  21.     }
  22. }
Advertisements

December 18, 2012 - Posted by | Uncategorized | ,

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: