Use jetbrains dottrace performance to debug the Silverlight code

Source: Internet
Author: User
Overview

Common performance debugging tools on the. NET platform include windbg, Ants performance profiler, jetbrains dottrace performance, CLR profiler, etc.

Windbg is relatively powerful, but it is also a complicated method to use. Windbg generally uses the input command. Windbg can view the number of objects in the current application memory. The address of each object and the dependency between objects. And dump out il. When we see that there shouldn't be so many objects of a certain type, we can try to randomly dump the dependencies of an object. Windbg's powerful functions are described in detail in Zhang yinkui's "software debugging.

Both ants performance profiler and dottrace take Memory snapshots. This section describes how to use dottrace in Silverlight.

Dottrace usage

1. Use dottrace 4.0 + vs2010 to debug Silverlight. Dottrace4.0 can be integrated into vs2010

2. When vs2010 is enabled, vs2010 virtual IIS webdev. webserver40 is started.

3. Click the vs menu dottrace à profile application à select Silverlight application and click OK. Enter the URL we want to run and click OK.

4. dottrace is started. By default, the monitoring status is enabled, that is, your current operations will be recorded by dottrace. If the content of the file is recorded throughout the process is relatively large, it is difficult for us to find what we need. Click to delete this snapshot record, and click to start a new snapshot. Click to obtain the monitored files and open the files. A colleague said that when data is edited in datafrom (Toolkit control), the state of an attribute of the current entity will be changed to another value, in addition, after debugging for half a day, I did not track where to change this value. (Because many code encapsulation layers run asynchronously, and entity is dynamically generated. Maybe the code we have written may not change the value. Therefore, debugging is difficult. Our project team has a layer of code encapsulated by other departments, and we cannot debug it ourselves. In short, my colleagues confirm that the Code on their own side has changed the value of this attribute) then, we click the blank space for data operations to monitor the process.

5. For a snapshot monitored by dottrace, there are tread tree, calltree, plain list, hot spots on the left.

. Press Ctrl + F to find the class and function.

Analysis: when the value of rowstate changes to deleted, the rowstate of the entity will be set. net runtime, access to properties will generate a set _ property name method, enter set_rowstate. The set_rowstate method is found. double-clicking set_rowstate will jump to the call tree of this method.

Analysis: we can clearly see in datafromde commitedit-> queryablecollectionview commitedit-> oncollectionchanged-> removerowsforoldentities. It is very likely that rowstate is used as the deleted state during removerowsforoldentities.

So why does the queryablecollectionview commitedit trigger the oncollectionchanged event? We know that oncollectionchanged is only triggered when the collection is removed or added. Does the queryablecollectionview commitedit trigger this action?

Next we will decompile the commitedit method of queryablecollectionview.

The commitedit method calls the refreshonitemaction method. In the refreshonitemaction method, removeargs and addedargs are available when the Bush group status and queryablecollectionview paging status are displayed. It is assumed that an entity is removed first and then an entity is added. Let's take a look at the raisecollectionchangedonitemaction method again. You can simply add it and then remove it.

In the above example, we only use a small function of dottrace to view its calltree. Dottrace is mainly used to debug performance. We can see the percentage of time each method calls on the calltree. Of course, the value of the rowstate attribute cannot be confirmed here because of this. At least we know that this may cause this problem. Next we can debug these items in our code. Debugging usually involves locating several possible problems and then troubleshooting them one by one. The tool can only help us locate possible problems. If we do not narrow down the debugging scope first. Due to the large amount of code running, debugging may not be able to find the root cause of the problem. Here we will briefly introduce the preliminary usage of the dottrace tool.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.