C # performance optimization practices
Performance is an important indicator to consider the quality of a software product. It plays an equally important role in product functions. When you select a software product, you will test and compare the performance of similar products. It is one of the important factors for purchasing the software.
Performance of Software refers to performance optimization principles and how to discover performance bottlenecks
As mentioned in the previous section, the first step of performance optimization is to discover performance bottlenecks. This section describes some practices for locating performance bottlenecks.
Performance Optimization Methods and Techniques
There are many solutions after locating performance problems. This section describes some performance optimization techniques and practices.
Cache
Cache is the most commonly used Optimization Method in performance optimization. It is applicable to frequent data acquisition, and it takes a long time to obtain the data each time. At this time, the method will be used during the first acquisition, and the data will be cached after the acquisition. Then use the cached data. If the cache optimization method is used, pay special attention to the synchronization of cached data. That is to say, if the actual data changes, the cached data should be cleared in a timely manner, make sure that no error data is used because of the cache. Example:
Improves response time asynchronously.
Understanding platform features
For example, the DP of WPF is very slow compared with the CLR property, including Get and Set, which is different from the general quality of Get. If a DP needs to be read multiple times, it is recommended that the CLR property be used for Cache.
Progress bar to improve user experience
Sometimes, none of the above solutions can quickly respond to user operations, progress bars, images that have been circled, and prompt text such as "Your operations may take a long time to wait ". Can improve user experience. It can be considered as the final solution.