Windows Phone本地数据库性能最佳实践
2012-04-14 22:53
253 查看
原文链接:http://windowsphonegeek.com/articles/Performance-Best-Practices-Windows-Phone-Mango-Local-Database
In this article I am going to talk about Windows Phone Mango Local Database Performance Best Practices. I will discuss three different ways in which you can improve the performance of your windows
phone app when working with a local database both in terms of speed and memory consumption. I will not only prove that the performance is really improved but will also measure exactly how much it is improved.(本文讨论Mango本地数据库最佳实践。将从三个方面来讨论如何改善wp数据库应用在速度及内存消耗方面的性能。不仅要改善程序的性能而且要量化到具体改善了多少。)
NOTE: "Local Database" comes with the Windows Phone 7.1 Mango update. Here are some of our previous posts you can take a look for reference:
Windows Phone Mango Local Database: mapping and database operations
Using SqlMetal to generate Windows Phone Mango Local Database classes
Local Database Performance Best Practices:
The most important techniques that you can use to improve the performance of your app(regarding Local Database) are:
Defining a Version Column in the Entity classes
Implementing INotifyPropertyChanging in the Entity classes
Using Compiled Queries
关于提升应用性能最重要的技术是:
在实体类中定义版本列 ColumnAttribute.IsVersion
在实体类中实现INotifyPropertyChanging
使用编译查询
For reference you can also take a look at the official MSDN documentation.
To begin with lets first create a new Windows Phone 7.1 Mango(in our case we will use the latest Beta version of the tools) application project. We will first create here a test setup that will be the base line for our testing and measurements.
首先,建立一个WP7.1应用。首先创建一个测试设置,这将是我们的测试和测量基准线。
The Baseline
We will use the following class without any improvements in order to test the baseline performance of the Local Database:
我们将使用下面的类,不做任何改善,作为本地数据库的性能测试基准:
public class PersonOptimized : IPerson, INotifyPropertyChanging
In this article I am going to talk about Windows Phone Mango Local Database Performance Best Practices. I will discuss three different ways in which you can improve the performance of your windows
phone app when working with a local database both in terms of speed and memory consumption. I will not only prove that the performance is really improved but will also measure exactly how much it is improved.(本文讨论Mango本地数据库最佳实践。将从三个方面来讨论如何改善wp数据库应用在速度及内存消耗方面的性能。不仅要改善程序的性能而且要量化到具体改善了多少。)
NOTE: "Local Database" comes with the Windows Phone 7.1 Mango update. Here are some of our previous posts you can take a look for reference:
Windows Phone Mango Local Database: mapping and database operations
Using SqlMetal to generate Windows Phone Mango Local Database classes
Local Database Performance Best Practices:
The most important techniques that you can use to improve the performance of your app(regarding Local Database) are:
Defining a Version Column in the Entity classes
Implementing INotifyPropertyChanging in the Entity classes
Using Compiled Queries
关于提升应用性能最重要的技术是:
在实体类中定义版本列 ColumnAttribute.IsVersion
在实体类中实现INotifyPropertyChanging
使用编译查询
For reference you can also take a look at the official MSDN documentation.
To begin with lets first create a new Windows Phone 7.1 Mango(in our case we will use the latest Beta version of the tools) application project. We will first create here a test setup that will be the base line for our testing and measurements.
首先,建立一个WP7.1应用。首先创建一个测试设置,这将是我们的测试和测量基准线。
The Baseline
We will use the following class without any improvements in order to test the baseline performance of the Local Database:
我们将使用下面的类,不做任何改善,作为本地数据库的性能测试基准: