Silverlight Performance Tip: 15 is better than the default 60

Thanks to Masykur (MVP ASP.NET – Indonesia) for pointing this out: Silverlight ePaper causes high CPU usage when hovering mouse over the text.

I have the solution to that (and a video to prove it), but first let me blame Microsoft for this point:

Silverlight uses CPU Rendering to redraw screens instead of Graphics Card (unlike DirectX or WPF).

Yes, they say Silverlight 3 supports GPU Acceleration, but I wonder on which cards it works (EnableCacheVisualization doesn’t seem to work on my Lenovo T400 and MacBook Pro, but on a Kompas.com engineer laptop it works).

So here’s my Silverlight Performance Tip: adjust your FrameRate according to your media. Since my media is static, I use 15fps. If you use video, make sure the video framerate matches Silverlight’s framerate. The default is 60fps.

So I guess that means on the default scenario, Silverlight will redraw my mouse cursor 60 times a second. That is not necessary as I don’t need the smoothness.

Here’s the video to show that 15fps is a big improvement than the default 60fps:

On the default 60fps, you can see the CPU usage jumped to 24% (this being on QuadCore with 8GB RAM).

On the custom 15fps, you can see the CPU usage is always below 10%.

You need to maximize the video to see the numbers…

 

Oh, here’s the code to make the changes:

void Main_Loaded(object sender, RoutedEventArgs e)
{
    var host = Application.Current.Host;
    var settings = host.Settings;
    // Performance Visualization
    settings.EnableFrameRateCounter = true;
    settings.EnableRedrawRegions = true;
    settings.MaxFrameRate = 15;
}
Share this post: | | | |
Published Monday, January 11, 2010 12:19 AM by zeddy

Comments

# re: Silverlight Performance Tip: 15 is better than the default 60

Monday, January 11, 2010 8:52 AM by Xtradi

the same for geeks forum's silverlight

# re: Silverlight Performance Tip: 15 is better than the default 60

Monday, January 11, 2010 9:21 AM by Narenda Wicaksono

mantabs! ini berguna :)

# re: Silverlight Performance Tip: 15 is better than the default 60

Monday, January 11, 2010 11:33 AM by Dicky Arinal

I like this!

Simple yet useful

# re: Silverlight Performance Tip: 15 is better than the default 60

Monday, January 11, 2010 8:46 PM by cahnom

Z,

Your ePaper consume lot of CPU because your silverlight application is using windowless setting to true. Silverlight will use browser rendering engine instead of Silverlight rendering engine if using windowless mode.

Every changes of Silverlight elements including moving cursor will render all silverlight elements. If you are using windowless set to false, Silverlight will use internal rendering engine and render part of area, not all element.

# re: Silverlight Performance Tip: 15 is better than the default 60

Monday, January 11, 2010 9:02 PM by zeddy

@cahnom: i need windowless for the Right-Click Menu. Unless Kompas removes the Right-Click requirement

# Silverlight Performance Tip: WindowLess is an Anomaly

Monday, January 11, 2010 9:57 PM by Z & his Startup

Once again, ol’ Masykur reminded me of something in this comment : that I could boost the performance

Powered by Community Server (Commercial Edition), by Telligent Systems