title: PerfView: Analyzing Performance of App including Database Calls
body: <p>I'm currently getting into PerfView for performance analysis for my (C#) apps.
  But typically those apps use a lot of database calls.
  So I asked myself questions like:
  - How much time is spent in Repositories?
  - (How much time is spent waiting for SQL Queries to return?) -> I don't know if this is even possible to discover with PerfView</p>
  
  <p>But from my traces I get barely any useful results. In the "Any Stacks" View it tells me (when I use grouping on my Repository) that 1,5 seconds are spent in my Repsoitory (the whole call is about 45 seconds). And i know this is not really true, because the repositories calls the database A LOT. </p>
  
  <p>Is it just that CPU metric is not captured when waiting for SQL Queries to complete because CPU has nothing to do in this period of time and therefore my times are just including data transformation times etc in the repository?</p>
  
  <p>Thanks for any help!</p>
  
  <p>EDIT:</p>
  
  <p>What i missed is turning on thread times option to get times of blocked code (which is what's happening during database calls i suppose). I got all the stacks now, just have filter out the uninteresting things. But i don't seem to get anywhere.</p>
  
  <p>What's especially interesting for me when using "Thread Time" is the BLOCKED_TIME. But with it the times are off i think. When you look at the screenshot, it tells me that CPU_TIME is 28,384. Which is milliseconds (afaik), but BLOCKED_TIME is 2,314,732, which can't be milliseconds. So percentage for CPU_TIME is very low with 1.2% but 28 out of 70 seconds are still a lot. So the Inclusive Percentage time is comparing apples and oranges here. Can somebody explain?</p>
  
  <p><img src="https://i.stack.imgur.com/G1mp5.jpg" alt="PerfView &quot;Thread Time Stacks&quot; View after about 70 seconds analysis of a WCF service call"></p>