Presentation is loading. Please wait.

Presentation is loading. Please wait.

.NET Compact Framework Performance Strategies MBL 402 Ivo Salmre Product Manager.NET Developer Technologies, UK Microsoft Corporation.

Similar presentations


Presentation on theme: ".NET Compact Framework Performance Strategies MBL 402 Ivo Salmre Product Manager.NET Developer Technologies, UK Microsoft Corporation."— Presentation transcript:

1 .NET Compact Framework Performance Strategies MBL 402 Ivo Salmre Product Manager.NET Developer Technologies, UK Microsoft Corporation

2 Agenda Introduction.NET Compact Framework performance characteristics Process for maximizing application performance Tips and tricks Summary

3 Agenda Introduction.NET Compact Framework performance characteristics Process for maximizing application performance Tips and tricks Summary

4 What Is Performance? Affected by two principles Absolute Performance of the system; the raw processing horsepower Apparent Performance of the application; affected by how the application is written Application performance is qualitatively measured by how responsive the application is to the end user

5 Key Considerations Keep target hardware in mind Think constrained, think mobile Use only what you really need Where is performance important? Start-up? Data Access? What is causing the slow down? Does the user need to know the slow down exists?

6 Agenda Introduction.NET Compact Framework performance characteristics Process for maximizing application performance Tips and tricks Summary

7 Performance Overview High performing execution engine Graphics and user interface performance Data and XML performance

8 How we’re doing… TestTech Preview Today Rectangles/sec70749 Ellipses/sec61641 4-Pixel Segs/sec 63938 Windows/sec1.75.4 XMLRead/564K161 sec18 sec RemoteMethod16 sec1 sec *Performance numbers taken using a 204 MHz, Strong ARM Powered PocketPC device We’ve come a long way, baby!

9 Size Data AreaSize (KB) Execution Engine (Native Code and Binary Data)469 Base Classes350 WebSerices/XML130 Drawing/Forms190 Data (ADO.NET)175 Visual Basic.NET Run-Time Library56 TOTAL:1370 *Size numbers taken on Windows CE.NET device with a Strong ARM processor

10 The EE A short review Compiled managed code is a binary in Microsoft Intermediate Language Code is just-in-time compiled to the native processor language on type-by-type, method-by- method basis Resulting native code is cached for later reuse Over the lifetime of the app, the up front cost of jitting is amortized, and becomes less and less significant

11 Code Pitching Occurs when large volumes of allocated memory cause memory pressure Runtime will discard or pitch code from the code cache Qualitative inspection will tell you when this occurs

12 Behavior Under Memory Pressure Memory utilization Performance

13 User Interface Performance Version 1 performance is excellent! System.Drawing and System.Windows.Forms call to native APIs beneath Made more efficient by “batching” them where possible across the managed/native boundary Pools and reuses Window Handles

14 Data And XML Performance Version 1 performance is good Most of stack is implemented entirely in managed code Remember that absolute performance is affected by memory pressure

15 Agenda Introduction.NET Compact Framework performance characteristics Process for maximizing application performance Tips and tricks Summary

16 Use Methodical Process Analyze Performance of Application Discover where the application is slow Choose where to optimize What’s important to the customer scenarios? Understand what the APIs are doing Does the API do more than you need? Different scenarios call for different performance priorities

17 Understand The APIs How abstract is the API? Example: XmlDocument versus XmlTextReader/Writer What work has to happen under the hood? Be aware of how events fire Don’t do a lot of work in a click event if a user will be tapping and dragging object

18 Benchmarking Tips Isolate exactly what is being measured Keep microbenchmark test times > 10sec Repeat tests 3-5 times Ensure comparison of Apples to Apples Use real code when possible Test multiple designs and strategies Understand the differences or variation

19 Perf Stats Logged to a file on the device nObjectsAllocated, nCurrentObjectsAllocated Collect time is a function of current object count nSimple/Compact/FullCollections More compact  full collections under memory pressure msFullLatency Maximum app pause due to collection Determined by number of live objects cbJittedNative, nMethodsJitted How much native code is being generated? cbPitched, nMethodsPitched More code pitched under memory pressure Enabled via Registry Key

20 Alerts Client

21 Alerts Client Overview AlertsDB.xml DataSet Treeview Server Populates Populates Synced

22 Alerts Client Design strategies DataSet.ReadXML() 20 seconds total load time XMLTextReader – Forward Data Loading File Read Time 6 seconds (Total: 11 seconds) TreeView Load Time slow XMLTextReader + Delay TreeView Population File Read Time 2 seconds (Total: 3-4 seconds) TreeView Load Time faster SQL Server CE + Delay TreeView Population Query Time 3 seconds (Total: 3-4 seconds) TreeView Load Time faster (same as above)

23 Alerts Client Design strategies 1. DataSet.ReadXML() 20 seconds total load time 2. XMLTextReader – Forward Data Loading File Read Time 6 seconds (Total: 11 seconds) TreeView Load Time slow 3. XMLTextReader + Delay TreeView Population File Read Time 2 seconds (Total: 3-4 seconds) TreeView Load Time faster 4. SQL CE + Delay TreeView Population Query Time three seconds (Total: 3-4 seconds) TreeView Load Time faster (same as above)

24 Alerts Client Lessons learned Methodical process, iterate on multiple designs Be creative! Understanding APIs being used Think of the user scenario Here, no need for user to see sub nodes of Tree

25 Agenda Introduction.NET Compact Framework performance characteristics Process for maximizing application performance Tips and tricks Summary

26 Execution Engine Don’t call GC.Collect()! Minimize the number of function calls Consider making functions larger rather than having incredibly deep call stacks Make use of asynchronous calls where useful, but avoid creating too many threads Reduce, reuse, recycle! The less memory you allocate, the faster your app will be!

27 User Interface Reduce number of method calls Example use Control.Bounds instead of Control.Location + Control.Size Create the Window tree top down, rather than bottom up Opposite of what VS.NET does by default Minimize control addition on Form.Load() Defer loading of controls until they are used

28 Handling Data Defer data loading until it is required, discard when data no longer in use Minimize data in memory at any time Forward only reading is always faster than in memory representations XmlDocument versus XmlTextReader DataReader versus DataAdapter Use StringBuilder for complex string manipulations

29 Asynchronous Processing Always be on the look out for asynchronous processing Use built in asynchronous calls in network stack Create threads to do work that can be deferred, or that shouldn’t block user interface Network connections and data loading or synching are good candidates Update user interface using Control.Invoke() Let threads exit No Thread.Abort()

30 Asynch Network Requests WebService myWebService = new WebService(); IAsyncResult ar = BeginWebService(CallbackFunc, WebService); public static void CallbackFunc(IAsyncResult Result) { WebService myService = (WebService) Result.AsyncState; object[] RemoteObjects; RemoteObjects= myService.EndGetContactList(Result); }

31 Agenda Introduction.NET Compact Framework performance characteristics Process for maximizing application performance Tips and tricks Summary

32 Consider your user scenario Design, test and iterate on your design considering multiple approaches Methodically analyze performance of your application Understand APIs Reduce, reuse and recycle objects Minimize data in memory

33 Community Resources http://www.microsoft.com/communities/default.mspx Most Valuable Professional (MVP) http://www.mvp.support.microsoft.com/ Newsgroups Converse online with Microsoft Newsgroups, including Worldwide http://www.microsoft.com/communities/newsgroups/default.mspx User Groups Meet and learn with your peers http://www.microsoft.com/communities/usergroups/default.mspx

34 Suggested Reading And Resources The tools you need to put technology to work! TITLEAvailable Microsoft®.NET Compact Framework (Core Reference): 0- 7356-1725-2 Today Microsoft Press books are 20% off at the TechEd Bookstore Also buy any TWO Microsoft Press books and get a FREE T-Shirt

35 evaluations evaluations

36 © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.


Download ppt ".NET Compact Framework Performance Strategies MBL 402 Ivo Salmre Product Manager.NET Developer Technologies, UK Microsoft Corporation."

Similar presentations


Ads by Google