diff options
| author | Roger Barnes | 2012-09-06 17:48:05 +1000 | 
|---|---|---|
| committer | Roger Barnes | 2013-05-01 19:27:25 +1000 | 
| commit | 50fa93a503d1ac1ed1a6b72e6390cc97067f555d (patch) | |
| tree | a5356cc489a4d0586ffbcd4f89f67fcd4485cb07 /debug_toolbar/templates | |
| parent | 5ae6fcc61c7596b4980e85186f3737fad01a0ad4 (diff) | |
| download | django-debug-toolbar-50fa93a503d1ac1ed1a6b72e6390cc97067f555d.tar.bz2 | |
Add javascript timing metrics to timing panel onLoad if available
Diffstat (limited to 'debug_toolbar/templates')
| -rw-r--r-- | debug_toolbar/templates/debug_toolbar/panels/timer.html | 60 | 
1 files changed, 60 insertions, 0 deletions
diff --git a/debug_toolbar/templates/debug_toolbar/panels/timer.html b/debug_toolbar/templates/debug_toolbar/panels/timer.html index f267de1..d30bbf4 100644 --- a/debug_toolbar/templates/debug_toolbar/panels/timer.html +++ b/debug_toolbar/templates/debug_toolbar/panels/timer.html @@ -1,4 +1,5 @@  {% load i18n %} +<h4>{% trans 'Resource Usage' %}</h4>  <table>  	<colgroup>  		<col style="width:20%"/> @@ -19,3 +20,62 @@  		{% endfor %}  	</tbody>  </table> + +<div id="djDebugBrowserTiming" style="display:none"> +	<h4>{% trans 'Browser Timing' %}</h4> +	<table> +		<colgroup> +			<col style="width:20%"/> +			<col/> +		</colgroup> +		<thead> +			<tr> +				<th>{% trans "Timing Attribute" %}</th> +				<th>{% trans "Value" %}</th> +			</tr> +		</thead> +		<tbody id="djDebugBrowserTimingTableBody"> +		</tbody> +	</table> +</div> +<script> +	(function(w, d) { +		function _renderPerf() { +			var perf = w.performance || w.msPerformance || +						w.webkitPerformance || w.mozPerformance; +			if (perf) { +				var rowCount = 0, +					timingOffset = perf.timing.navigationStart; +				function addRow(stat) { +					rowCount++; +					var row = document.createElement('tr'), +					    keyCell = document.createElement('td'), +						valueCell = document.createElement('td'); +					row.className = (rowCount % 2) ? 'djDebugOdd' : 'djDebugEven'; +					keyCell.innerHTML = stat; +					valueCell.innerHTML = (perf.timing[stat] - timingOffset) + " msec"; +					row.appendChild(keyCell); +					row.appendChild(valueCell); +					d.getElementById('djDebugBrowserTimingTableBody').appendChild(row); +				} + +				addRow('requestStart'); +				addRow('responseStart'); +				addRow('responseEnd'); +				addRow('domLoading'); +				addRow('domInteractive'); +				addRow('domComplete'); +				addRow('loadEventStart'); +				addRow('loadEventEnd'); +				d.getElementById('djDebugBrowserTiming').style.display = "block"; +			} +		} + +		function renderPerf() { +			setTimeout(_renderPerf, 1000); +		} + +		if (w.addEventListener) { w.addEventListener("load", renderPerf, false); } +  		else if (w.attachEvent) { w.attachEvent("onload", renderPerf); } +	}(window, document)); +</script>  | 
