Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Make sure that you really know what you're looking for in the profiler you're writing, whenever you're collecting the total execution time of a certain piece of code, it will include time spent in all its children and it may be hard to really find what is the bottleneck in your system as the most top-level function will always bubble up as the most expensive one - like for instance main().</p> <p>What I would suggest is to hook into every function's prologue and epilogue (if your application is a CLR application, you can use the <a href="http://msdn.microsoft.com/en-us/library/ms231434.aspx" rel="nofollow"><code>ICorProfilerInfo::SetEnterLeaveFunctionHooks</code></a> to do that, you can also use macros at the beginning of every method, or any other mechanism that would inject your code at the beginning and and of every function) and collect your times in a form of a tree for each thread that your profiling.</p> <p>The algorithm for this would look somehow similar to this:</p> <ul> <li>For each thread that you're monitoring create a stack-like data structure.</li> <li><p>Whenever you're notified about a function that began execution, push something that would identify the function into that stack. </p> <ul> <li>If that function is not the only function on the stack, then you know that the previous function that did not return yet was the one that called your function.</li> <li>Keep track of those callee-called relationships in your favorite data structure.</li> </ul></li> <li><p>Whenever a method returns, it's identifier will always be on top of its thread stack. It's total execution time is equal to (time when the last (it's) identifier was pushed on the stack - current time). Pop that identifier of the stack.</p></li> </ul> <p>This way you'll have a tree-like breakdown of what eats up your execution time where you can see what child calls account for the total execution time of a function.</p> <p>Have fun!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload