DCSIMG
Silverlight 3 Quick Tip: Analytics - Alex Golesh's Blog About Silverlight Development

Silverlight 3 Quick Tip: Analytics

Silverlight 3 has new feature which should help us to understand how good our application performs. This feature is Analytics class. It Has 2 read-only properties

AverageProcessLoad – average CPU used by this process across all the cores

AverageProcessorLoad – average CPU usage across all cores

In addition it has GpuCollection collection with objects of GpuInformation type. Each one of GpuInformation object provides information about:

DeviceId – device ID of the GPU

VendorId – vendor ID of the GPU

DriverVersion – video drivers version

 

Quick usage sample – show CPU usage:

Code behind:

public partial class MainPage : UserControl
{
  private Analytics theAnalytics;

  public MainPage()
  {
    InitializeComponent();

    theAnalytics = new Analytics();

    DispatcherTimer timer = new DispatcherTimer();
    timer.Interval = TimeSpan.FromSeconds(1);
    timer.Tick += (s, e) =>
      {
        txtCPULoad.Text = theAnalytics.AverageProcessorLoad.ToString();
        txtSLCPULoad.Text = theAnalytics.AverageProcessLoad.ToString();
      };
    timer.Start();
  }
}

XAML:

<StackPanel x:Name="LayoutRoot">
  <StackPanel Orientation="Horizontal">
    <TextBlock Text="Average CPU Load:"/>
    <TextBlock x:Name="txtCPULoad"/>
    <TextBlock Text="%"/>
  </StackPanel>
  <StackPanel Orientation="Horizontal">
    <TextBlock Text="Average Silverlight CPU Load:"/>
    <TextBlock x:Name="txtSLCPULoad"/>
    <TextBlock Text="%"/>
  </StackPanel>
</StackPanel>

Running application:

image

 

 

Enjoy,

Alex

Published Friday, July 10, 2009 4:33 PM by Alex Golesh

Comments

# Silverlight 3 Quick Tips

Pingback from  Silverlight 3 Quick Tips

Saturday, July 11, 2009 12:05 PM by Silverlight 3 Quick Tips

# Silverlight 3 Quick Tip: Analytics - DevCorner

Thank you for submitting this cool story - Trackback from NewsPeeps

Saturday, July 11, 2009 4:01 PM by NewsPeeps

# re: Silverlight 3 Quick Tip: Analytics

Just wondering - is device ID unique? Does it mean I can authenticate my users (or their machines)?

Saturday, August 08, 2009 11:59 AM by Somebody

# re: Silverlight 3 Quick Tip: Analytics

Somebody:

DeviceID is a GPU model identification (GForce 9300M, GForce 9800GTX, Intel 4500M, ATi Radeon HD 4850), VendorID is a GPU maker identification (NVidia, ATi, Intel, etc.)... It is not a chip number :)

Regards,

Alex

Sunday, August 09, 2009 11:58 AM by Alex Golesh

# Silverlight ?le Veritaban? ??lemleri

Pingback from  Silverlight ?le Veritaban? ??lemleri

Sunday, January 16, 2011 5:14 PM by Silverlight ?le Veritaban? ??lemleri

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above: