Using dottace to simulate Lao Zhao's "using profiler to analyze program performance"

Source: Internet
Author: User

Recently I saw Lao Zhao blog "using profiler to analyze program performance" (http://www.cnblogs.com/JeffreyZhao/archive/2009/12/22/profiler-sampling.html ),

It was mentioned that in order to solve the problem of failure to trace method calls within the framework, Lao Zhao introduced the method of tracing with Profiler. many of his friends did not use profilter in vs versions.

I now use a third-party tool jetbrains dottrace to simulate it.

Next, we will prepare a piece of code to copy the ready-made code of Lao Zhao, saving a few minutes for the company to write code.

static void Main(string[] args){    var array = Enumerable.Range(1, 5).Select(i => new String((char)(i + 97), 5)).ToArray();    TestConvert(array);    TestParse(array);    TestTryParse(array);}private static List<Int32> TestParse(String[] strings){    Int32 intValue;    List<Int32> intList = new List<int>();    for (int i = 0; i < 100000; i++)    {        intList.Clear();        foreach (String str in strings)        {            try            {                intValue = Int32.Parse(str);                intList.Add(intValue);            }            catch (System.ArgumentException)            { }            catch (System.FormatException)            { }            catch (System.OverflowException)            { }        }    }    return intList;}private static List<Int32> TestTryParse(String[] strings){    Int32 intValue;    List<Int32> intList = new List<int>();    Boolean ret;    for (int i = 0; i < 100000; i++)    {        intList.Clear();        foreach (String str in strings)        {            ret = Int32.TryParse(str, out intValue);            if (ret)            {                intList.Add(intValue);            }        }    }    return intList;}private static List<Int32> TestConvert(String[] strings){    Int32 intValue;    List<Int32> intList = new List<int>();    for (int i = 0; i < 100000; i++)    {        intList.Clear();        foreach (String str in strings)        {            try            {                intValue = Convert.ToInt32(str);                intList.Add(intValue);            }            catch (System.FormatException)            { }            catch (System.OverflowException)            { }        }    }    return intList;}
Select dottrace-Profiler startup project in the menu to start
 
Click "run" to start our console program. There is a dottrace tool page.
 
Click "Get snapshot" to get the "log" for running the console program"
Let's take a look at the "call tree" similar to profiler"
 

For example, the structure of the call tree on the left is the code you wrote on the right. We can see the percentage of time used compared to the upper-level tree node, the number of calls, the time spent. Of course, the calling methods inside the framework can also be seen, but the Code cannot be seen. In the code area on the right, there is "edit in Visual Studio". We can directly drop into vs to edit the code.

My friends may have noticed that there are also threads tree plain list hot spot. Let's take a look at "Threads Tree" one by one ",

 

Here we can see the call tree of each thread.

Plain list

 

Host spots

 

Of course, we can also quickly search by function or class, press "Ctrl + F"

I think it is quite convenient. If you are interested, you can install it for fun. Dottrace can not only debug the standard donet program, but also debug Silverlight. Recently I used dottrace to debug Silverlight (debug Silverlight: http://www.cnblogs.com/ForrestZhang/archive/2010/12/22/1914158.html)

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.