Presentation is loading. Please wait.

Presentation is loading. Please wait.

Windows Phone: Optimizing Application Performance

Similar presentations


Presentation on theme: "Windows Phone: Optimizing Application Performance"— Presentation transcript:

1 Windows Phone: Optimizing Application Performance
12/6/2018 4:06 AM WPH303 Windows Phone: Optimizing Application Performance Maarten Struys Windows Phone Evangelist Alten PTS © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

2 Agenda Introduction Identifying Performance Issues
TechEd 2012 12/6/2018 4:06 AM Agenda Introduction Identifying Performance Issues Obvious Performance Improvement Lessons Reducing Startup Time and Memory Footprint Understand UI Elements and Data Binding Advanced Performance Improvement Lessons Using Separate Assemblies Using inline Code Summary © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

3 Introduction The Importance of Performance
TechEd 2012 12/6/2018 4:06 AM Introduction The Importance of Performance Windows Phones are Powerful Modern, fast GPU / CPU combination Be aware of power consumption in combination with functionality Performance is influenced by Code executing on the UI Thread Graphic features used inside applications Data binding / storage strategies Less is More! © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

4 Introduction Performance Aware Software Development
TechEd 2012 12/6/2018 4:06 AM Introduction Performance Aware Software Development Balance performance with other requirements Turn performance into a functional requirement Identify and evaluate performance issues Maximum allowed (acceptable) execution time/resource usage Test early and frequently Use common scenarios Test on (multiple) device(s) Watch out for regression © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

5 Introduction Important Assumptions
TechEd 2012 12/6/2018 4:06 AM Introduction Important Assumptions Emulator performance ≠ device performance Test on both 512 and 256 MB versions Test on real device(s) Test realistic scenarios Use Mobile Network for data connections Use release builds of your application Run detached from the debugger © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

6 Introduction Performance influenced by
TechEd 2012 12/6/2018 4:06 AM Introduction Performance influenced by Application startup time XAML parsing Initialization code Threading Model Graphics Stack Frame rate Animation Media UI Model Layout Virtualization Data binding Scrolling Data connections © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

7 Identifying Performance Issues Use ‘Cool’ UI Elements with care
TechEd 2012 12/6/2018 4:06 AM Identifying Performance Issues Use ‘Cool’ UI Elements with care When are items loaded? Panorama versus Pivot ListBox StackPanel versus Virtualizing StackPanel Images Dynamic size versus hard coded Showing progress ProgressBar vs PerformanceProgressBar vs ProgressIndicator © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

8 Identifying Performance Issues Using common sense
TechEd 2012 12/6/2018 4:06 AM Identifying Performance Issues Using common sense Don’t execute hidden animations Hiding UI elements through Opacity or Visibility Using images or XAML Use the ‘right’ type of Map (full Bing Map Control or static Map created with REST API’s) Programming Language / Class Library Features String versus StringBuilder Be aware of memory leaks (anonymous event handlers) © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

9 Measuring Performance An iterative action, execute frequently
TechEd 2012 12/6/2018 4:06 AM Measuring Performance An iterative action, execute frequently Understand the startup behavior of your application Know your application’s memory footprint Will it run on 256 MB devices? Monitor screen updates while executing the application Test on real devices regularly Device Emulator will find performance behavior trends Your application might run fine on the emulator but sluggish on a real device © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

10 Measuring Performance Using performance counters
TechEd 2012 12/6/2018 4:06 AM Measuring Performance Using performance counters The easiest way to measure performance Performance Counters are already there Visible when attached to the debugger Add Peter Torr’s MemoryDiagnosticsHelper Indication of used memory Counter Ideal Minimum Best Experience Render Thread 30 fps 60 fps UI Thread 15 fps > 15 fps Screen fill rate 2.0 <= 1.0 © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

11 Improving Application Startup Time
12/6/2018 4:06 AM demo Improving Application Startup Time © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

12 Target the latest device types Benefit from Fast Application Switching
TechEd 2012 12/6/2018 4:06 AM Target the latest device types Benefit from Fast Application Switching Better user experience Switching between applications often transparent for end users Enabled for Windows Phone 7.5 (including 256 MB Devices) Recompile, test, and resubmit your existing WP7 applications OnNavigatedFrom/Deactivated Save page/application state OnNavigatedTo/Activated Restore page/application state if tombstoned only Detach / Attach resources manually, especially on 256 MB Devices © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

13 Memory usage and Performance Understanding Garbage Collections
TechEd 2012 12/6/2018 4:06 AM Memory usage and Performance Understanding Garbage Collections Garbage Collector helps to prevent common errors Can’t use memory you already freed Will free memory you don’t use anymore Garbage Collections influence your application performance Memory Allocations trigger Garbage Collections Long living objects result in increasing memory usage Can worst case lead to OOM Exceptions Holding on to references unintentionally can result in memory leaks © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

14 TechEd 2012 12/6/2018 4:06 AM Using the Performance Analysis Tools Measuring and interpreting results Multiple Profiling options with the same tool Code Execution Profiler Memory Profiler Memory usage is an important performance influencer Visual Feedback about possible bottlenecks Use the tools frequently to understand graphs and reports © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

15 Identifying bottlenecks with Performance Analysis Tools
12/6/2018 4:06 AM demo Identifying bottlenecks with Performance Analysis Tools © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

16 Graphics Performance Threads that matter
TechEd 2012 12/6/2018 4:06 AM Graphics Performance Threads that matter Data binding, Rasterizing, Events, Very busy! UI Animations for bitmap cached elements Compositor Touch responsiveness thread Touch Application logic, long-running tasks, etc. Background Operating system compositing and overlays OS © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

17 TechEd 2012 12/6/2018 4:06 AM Background Processing Be nice to the UI Thread, your users will love you for it Long lasting operations will influence performance unless Running on separate threads Use BackgroundWorker or ThreadPool Use Asynchronous Methods (and be ready for the next version of Windows Phone) Almost as easy as synchronous methods without blocking the hosting thread Application complexity increases (slightly) Better end user experience Be also aware of battery consumption © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

18 Executing code asynchronously
12/6/2018 4:06 AM demo Executing code asynchronously © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

19 TechEd 2012 12/6/2018 4:06 AM Optimizing Even Further Trade off between maintainability and execution speed Startup time can decrease with small assemblies that are only loaded when they are needed Remove ‘redundant’ XAML Make use of inline code Worth investigating for frequently code Use the code execution profiling to identify frequently called methods Take advantage of GC behavior © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

20 Summary and Call to Action
TechEd 2012 12/6/2018 4:06 AM Summary and Call to Action Performance is crucial, especially on devices Know what is going on under the hood of your application Don’t execute code on the device … … unless it is absolutely necessary Visit to get the tools and to register as Windows Phone Developer Don’t wait for the next version of Windows Phone but start developing applications today! © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

21 Resources Learning TechNet http://europe.msteched.com
Connect. Share. Discuss. Microsoft Certification & Training Resources TechNet Resources for IT Professionals Resources for Developers

22 Submit your evals online
12/6/2018 4:06 AM Evaluations Submit your evals online © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

23 12/6/2018 4:06 AM © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION. © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

24 12/6/2018 4:06 AM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.


Download ppt "Windows Phone: Optimizing Application Performance"

Similar presentations


Ads by Google