Freigeben über


General best practices for performance

To deliver great performance for your Windows Store apps for Windows 8, think of performance as a feature. Plan for performance, and measure it early and throughout the lifecycle of your project. Users of Windows 8 expect their apps to remain responsive and feel natural. Treating performance as a feature will help you deliver on this expectation. We discuss general best practices for Windows Store apps using JavaScript and Windows Store apps using C++, C#, or Visual Basic.

Planning for performance

You must plan for every feature in your app, and the same is true for performance. Planning for performance consists of determining what your performance-critical scenarios will be, defining what good performance means, and measuring early enough in the development process to ensure that you can be confident in your ability to hit your goals.

You don't need to completely understand the platform to reason about where you might need to improve performance. By knowing what parts of your code execute most frequently, you can determine the best places to optimize your app.

The users' experience is a basic way to define good performance. For example, an app's startup time can influence a user's perception of its performance. A user might consider the performance of an app's launch time of less than one second to be excellent, less than 5 seconds to be good, and greater than 5 seconds to be poor.

Sometimes you also have to consider other metrics that don't have a direct impact on the user experience. An example of this is memory consumption. When an app uses large amounts of memory, it takes it from the rest of the system, causing the system as a whole to appear sluggish to the user. It is difficult to have a goal on overall sluggishness of the system, so having a goal on memory consumption is reasonable.

When defining your performance goals, take into consideration the perceived size of your app. Users’ expectations for the performance of your app may be influenced by their qualitative perception of how big your app is, and you should take into account whether your users will consider your app to be small, medium, or large. As an example, you might want a small app that doesn't use a lot of media to consume less than 100MB of memory.

For more info, see Plan for peformance.

Measuring your app’s performance

As part of your plan, you define all of the points during development where you will measure performance. Measuring performance serve different purposes depending on whether measure during the prototyping, development, or deployment phase of your project. In all cases, measure on a representative device so that you get accurate info. For more info about how to measure your app’s performance in Visual Studio, see Analyzing the performance of Windows Windows Store apps and the "Instrument for performance" section of Plan for peformance.

Measuring your app’s performance during the early stages of prototyping can add tremendous value to your project. We recommend that you measure performance as soon as you have code that does meaningful work. Early measurements give you a good idea of where the important costs are in your app, and inform design decisions. This results in high performing apps that scale well. It can be very costly to change design decisions later on in the project. Measuring performance too late in the product cycle can result in last minute hacks and poor performance.

Measuring your app’s performance during development time helps you:

  • Determine if you are on track to meet your goals.
  • If you are not on track, find out early if you need to make structural changes, such as data representation, in order to get back on track.

You don't need to optimize every part of your app, and performance improvements to the majority of your code usually don't result in a material difference to the user. Measure your app's performance to identify the high traffic areas in your code, and focus on getting good performance in only those areas. Often, there is a trade-off between creating software that follows good design practices and writing code that performs at the highest optimization. It is generally better to prioritize developer productivity and good software design in areas where performance is not a concern.

Windows 8 can run on many devices under a variety of circumstances and it is impossible for you to simulate all the conditions in which your app will run. Collecting telemetry about your app's performance on user machines can help you understand what your end-users are experiencing. This can be accomplished by adding instrumentation to various parts of your application and occasionally uploading the data to a web service. From this info, you can determine what the average user sees and what the worst and best case performance of your app is. This will help you decide which aspects of performance to focus on for the next version of your app.

The related topics contain more in-depth performance best-practices for developing Windows Store apps. These best practices cover topics that are likely to be the source of performance issues in your app. But these best practices will only make a difference if they are on performance critical paths of your app. We recommend that you follow the principles on this page and determine if applying these best practices will help you achieve your performance goals.

Plan for peformance

Performance best practices for Windows Store apps using JavaScript

Performance best practices for C# and Visual Basic