<script id=“profilerTemplate” type=“text/x-jquery-tmpl”>

<div class="profiler-result">

  <div class="profiler-button {{if has_duplicate_sql_timings}}profiler-warning{{/if}}">
  {{if has_duplicate_sql_timings}}<span class="profiler-nuclear">!</span>{{/if}}
    <span class="profiler-number">
      ${MiniProfiler.formatDuration(duration_milliseconds)} <span class="profiler-unit">ms</span>
    </span>
  </div>

  <div class="profiler-popup">
    <div class="profiler-info">
      <span class="profiler-name">
        ${name} <span class="profiler-overall-duration">(${MiniProfiler.formatDuration(duration_milliseconds)} ms)</span>
      </span>
      <span class="profiler-server-time">${machine_name} on ${MiniProfiler.renderDate(started)}</span>
    </div>
    <div class="profiler-output">
      <table class="profiler-timings">
        <thead>
          <tr>
            <th></th>
            <th>duration (ms)</th>
            <th class="profiler-duration-with-children">with children (ms)</th>
            <th class="time-from-start">from start (ms)</th>
          {{if has_sql_timings}}
            <th colspan="2">query time (ms)</th>
          {{/if}}
          {{each custom_timing_names}}
            <th colspan="2">${$value.toLowerCase()} (ms)</th>
          {{/each}}
          </tr>
        </thead>
        <tbody>
          {{tmpl({timing:root, page:this.data}) "#timingTemplate"}}
        </tbody>
        <tfoot>
          <tr>
            <td colspan="3">
              {{if !client_timings}}
              {{tmpl "#linksTemplate"}}
              {{/if}}
              <a class="profiler-toggle-duration-with-children" title="toggles column with aggregate child durations">show time with children</a>
            </td>
          {{if has_sql_timings}}
            <td colspan="2" class="profiler-number profiler-percent-in-sql" title="${MiniProfiler.getSqlTimingsCount(root)} queries spent ${MiniProfiler.formatDuration(duration_milliseconds_in_sql)} ms of total request time">
              ${MiniProfiler.formatDuration(duration_milliseconds_in_sql / duration_milliseconds * 100)}
              <span class="profiler-unit">% in sql</span>
            </td>
          {{/if}}
          {{each custom_timing_names}}
            <td colspan="2" class="profiler-number profiler-percentage-in-sql" title="${custom_timing_stats[$value].count} ${$value.toLowerCase()} invocations spent ${MiniProfiler.formatDuration(custom_timing_stats[$value].duration)} ms of total request time">
              ${MiniProfiler.formatDuration(custom_timing_stats[$value].duration / duration_milliseconds * 100)}
              <span class="profiler-unit">% in ${$value.toLowerCase()}</span>
            </td>
          {{/each}}
          </tr>
        </tfoot>
      </table>
      {{if client_timings}}
      <table class="profiler-timings profiler-client-timings">
        <thead>
          <tr>
            <th>client event</th>
            <th>duration (ms)</th>
            <th>from start (ms)</th>
          </tr>
        </thead>
        <tbody>
          {{each MiniProfiler.getClientTimings(client_timings)}}
          <tr class="{{if $value.isTrivial }}profiler-trivial{{/if}}">
            <td class="profiler-label">${$value.name}</td>
            <td class="profiler-duration">
              {{if $value.duration >= 0}}
              <span class="profiler-unit"></span>${MiniProfiler.formatDuration($value.duration)}
              {{/if}}
            </td>
            <td class="profiler-duration time-from-start">
              <span class="profiler-unit">+</span>${MiniProfiler.formatDuration($value.start)}
            </td>
          </tr>
          {{/each}}
        </tbody>
        <tfoot>
          <td colspan="3">
            {{tmpl "#linksTemplate"}}
          </td>
        </tfoot>
      </table>
      {{/if}}
    </div>
  </div>

{{if has_sql_timings}}
  <div class="profiler-queries">
    <table>
    <thead>
      <tr>
        <th style="text-align:right">step<br />time from start<br />query type<br />duration</th>
        <th style="text-align:left">call stack<br />query</th>
      </tr>
    </thead>
    <tbody>
      {{each(i, s) MiniProfiler.getSqlTimings(root)}}
        {{tmpl({ g:s.prevGap }) "#sqlGapTemplate"}}
        {{tmpl({ i:i, s:s }) "#sqlTimingTemplate"}}
        {{if s.nextGap}}
          {{tmpl({ g:s.nextGap }) "#sqlGapTemplate"}}
        {{/if}}
      {{/each}}
    </tbody>
    </table>
    <p class="profiler-trivial-gap-container">
      <a class="profiler-toggle-trivial-gaps" href="#">show trivial gaps</a>
    </p>
  </div>
{{/if}}

</div>

</script>

<script id=“linksTemplate” type=“text/x-jquery-tmpl”>

<a href="${MiniProfiler.shareUrl(id)}" class="profiler-share-profiler-results" target="_blank">share</a>
<a href="${MiniProfiler.moreUrl()}" class="profiler-more-actions">more</a>
{{if custom_link}}
<a href="${custom_link}" class="profiler-custom-link" target="_blank">${custom_link_name}</a>
{{/if}}
{{if has_trivial_timings}}
<a class="profiler-toggle-trivial" data-show-on-load="${has_all_trivial_timings}" title="toggles any rows with &lt; ${trivial_duration_threshold_milliseconds} ms">
  show trivial
</a>
{{/if}}

</script>

<script id=“timingTemplate” type=“text/x-jquery-tmpl”>

<tr class="{{if timing.is_trivial }}profiler-trivial{{/if}}" data-timing-id="${timing.id}">
  <td class="profiler-label" title="{{if timing.name && timing.name.length > 45 }}${timing.name}{{/if}}">
    <span class="profiler-indent">${MiniProfiler.renderIndent(timing.depth)}</span> ${timing.name.slice(0,45)}{{if timing.name && timing.name.length > 45 }}...{{/if}}
  </td>
  <td class="profiler-duration" title="duration of this step without any children's durations">
    ${MiniProfiler.formatDuration(timing.duration_without_children_milliseconds)}
  </td>
  <td class="profiler-duration profiler-duration-with-children" title="duration of this step and its children">
    ${MiniProfiler.formatDuration(timing.duration_milliseconds)}
  </td>
  <td class="profiler-duration time-from-start" title="time elapsed since profiling started">
    <span class="profiler-unit">+</span>${MiniProfiler.formatDuration(timing.start_milliseconds)}
  </td>

{{if timing.has_sql_timings}}
  <td class="profiler-duration {{if timing.has_duplicate_sql_timings}}profiler-warning{{/if}}" title="{{if timing.has_duplicate_sql_timings}}duplicate queries detected - {{/if}}{{if timing.executed_readers > 0 || timing.executed_scalars > 0 || timing.executed_non_queries > 0}}${timing.executed_readers} reader, ${timing.executed_scalars} scalar, ${timing.executed_non_queries} non-query statements executed{{/if}}">
    <a class="profiler-queries-show">
      {{if timing.has_duplicate_sql_timings}}<span class="profiler-nuclear">!</span>{{/if}}
      ${timing.sql_timings.length} <span class="profiler-unit">sql</span>
    </a>
  </td>
  <td class="profiler-duration" title="aggregate duration of all queries in this step (excludes children)">
    ${MiniProfiler.formatDuration(timing.sql_timings_duration_milliseconds)}
  </td>
{{else}}
  <td colspan="2"></td>
{{/if}}

{{each page.custom_timing_names}}
  {{if timing.custom_timings && timing.custom_timings[$value]}}
    <td class="profiler-duration" title="aggregate number of all ${$value.toLowerCase()} invocations in this step (excludes children)">
      ${timing.custom_timings[$value].length} ${$value.toLowerCase()}
    </td>
    <td class="profiler-duration" title="aggregate duration of all ${$value.toLowerCase()} invocations in this step (excludes children)">
      ${MiniProfiler.formatDuration(timing.custom_timing_stats[$value].duration)}
    </td>
  {{else}}
    <td colspan="2"></td>
  {{/if}}
{{/each}}

</tr>

{{if timing.has_children}}
  {{each timing.children}}
    {{tmpl({timing: $value, page: page}) "#timingTemplate"}}
  {{/each}}
{{/if}}

</script>

<script id=“sqlTimingTemplate” type=“text/x-jquery-tmpl”>

<tr class="${s.row_class}" data-timing-id="${s.parent_timing_id}">
  <td class="profiler-info">
    <div>${s.parent_timing_name}</div>
    <div class="profiler-number"><span class="profiler-unit">T+</span>${MiniProfiler.formatDuration(s.start_milliseconds)} <span class="profiler-unit">ms</span></div>
    <div>
      {{if s.is_duplicate}}<span class="profiler-warning">DUPLICATE</span>{{/if}}
      ${MiniProfiler.renderExecuteType(s.execute_type)}
    </div>
    <div title="{{if s.execute_type == 3}}first result fetched: ${s.first_fetch_duration_milliseconds}ms{{/if}}">${MiniProfiler.formatDuration(s.duration_milliseconds)} <span class="profiler-unit">ms</span></div>
  </td>
  <td>
    <div class="query">
      <pre class="profiler-stack-trace">${s.stack_trace_snippet}</pre>
      <pre class="prettyprint lang-sql"><code>${s.formatted_command_string}   </code></pre>
    </div>
  </td>
</tr>

</script>

<script id=“sqlGapTemplate” type=“text/x-jquery-tmpl”>

<tr class="profiler-gap-info{{if g.duration < 4}} profiler-trivial-gaps{{/if}}">
  <td class="profiler-info">
    ${g.duration} <span class="profiler-unit">ms</span>  
  </td>
  <td class="query">
    <div>${g.topReason.name} &mdash; ${g.topReason.duration.toFixed(2)} <span class="profiler-unit">ms</span></div>
  </td>
</tr>

</script>