Tags: , , , , , , , | Categories: Silverlight Posted by toddpi314 on 3/14/2009 12:28 PM | Comments (0)

Read this article in your language IT | EN | DE | ES

Silverlight has its limitations.

For one, the Silverlight Unit Test framework (ScottGu), although beautifully built, does not integrate well into any performance tuning harnesses. Out-of-the-box you get an export provider that meets the requirements to import into the VS.NET 2008 Performance Analyzer. This opens up the path to doing Line-Item Comparisons between benchmark sessions. But, the process of testing your Silverlight application, importing into VS.NET, and Comparing is kind of painful.

Another problem is Microsoft’s Expectation that minor Applications, like Widgets and Streaming Video, are the primary usage of the semi-portable framework. But, what about HTML Interpreter, Spreadsheet Engines, Peer-to-Peer collaboration (using the nifty Duplex features). What is the use of client side processing if you cannot get a myriad of little muscles to do the lifting?

So, how do we utilize the existing VS.NET Tools to run benchmarks on Silverlight Projects?

Create a Class Library to house the Model that uses the Compiler Directive to check for the SILVERLIGHT flag.

Public Sub DoWork() Implements IWorkHarness.DoWork        
System.Threading.Thread.Sleep(5)
#If SILVERLIGHT Then        
System.Threading.Thread.Sleep(10)
#End If    
End Sub

Then, create an additional Project in WPF that will link the files over for compilation.

Example:

1.image Create Silverlight Class Library
2. imageThrow together your Implementation with the Bridge Pattern, knowing that some items are not supported in WPF.
  • Remove all of your dependencies on the SL Framework out as far as you can away from the Model. Inheriting/Implementing any Silverlight features should exist only at the concrete level aside fundamental types like System.Object.
  • Generally, the Bridge Pattern was built just for this type of situation: Silverlight is a subset of WPF; common objects can be used to define your Model/Controllers while all real ‘Flavor’ specific items can be added via dependency injection. So, feel free to use System.Object, and other fundamental types. Rule of Thumb: If you have to add any new Framework DLLs to your Default Project Imports, there is a good chance the item contains something that is not supported in WPF.
  • Feel free to use a tool like Reflector, try the File Dissassembler Add-in, on the Core Silverlight Framework DLLs to extract your interfaces. (that may be faster in some scenarios than using the Object Browser
3.imageCreate WPF Class Library. This will be our WPF Skeleton to represent our project.
4. imageRight Click on WPF Class Library Project and select Add->Existing Item. Then, Search for all *.vb/*.cs files in your Silverlight Libraries Project Folder
5.image Select all code files, Drop Down Add Button and select “Add as Link”
6.imageCreate Application Fixture to mount Performance Analysis Tool.
  • Add the WPF Class Library Skeleton as a reference
  • In the application, create a Class/Method to define the workload
  • Implement any necessary concrete types that are specific to the WPF Framework Flavor
7image.Use Analyze Menu Option in VS.NET to tune

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Comments

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading