diff options
| author | Roger Barnes | 2013-03-24 22:08:08 +1100 | 
|---|---|---|
| committer | Roger Barnes | 2013-05-01 19:27:25 +1000 | 
| commit | ea60df8f6a3973c91595bf42f6b3f0d3d288824c (patch) | |
| tree | e6a6a74bd315f098d8c56747362fd199d93c5670 /debug_toolbar/templates | |
| parent | 50fa93a503d1ac1ed1a6b72e6390cc97067f555d (diff) | |
| download | django-debug-toolbar-ea60df8f6a3973c91595bf42f6b3f0d3d288824c.tar.bz2 | |
Waterfall timeline or browser events
Diffstat (limited to 'debug_toolbar/templates')
| -rw-r--r-- | debug_toolbar/templates/debug_toolbar/panels/timer.html | 53 | 
1 files changed, 40 insertions, 13 deletions
diff --git a/debug_toolbar/templates/debug_toolbar/panels/timer.html b/debug_toolbar/templates/debug_toolbar/panels/timer.html index d30bbf4..aae540f 100644 --- a/debug_toolbar/templates/debug_toolbar/panels/timer.html +++ b/debug_toolbar/templates/debug_toolbar/panels/timer.html @@ -31,7 +31,8 @@  		<thead>  			<tr>  				<th>{% trans "Timing Attribute" %}</th> -				<th>{% trans "Value" %}</th> +				<th class="timeline">{% trans 'Timeline' %}</th> +				<th class="time">{% trans "Time since navigation start (+length, msec)" %}</th>  			</tr>  		</thead>  		<tbody id="djDebugBrowserTimingTableBody"> @@ -41,32 +42,58 @@  <script>  	(function(w, d) {  		function _renderPerf() { +			// Browser timing is hidden unless we can successfully access the performance object  			var perf = w.performance || w.msPerformance ||  						w.webkitPerformance || w.mozPerformance;  			if (perf) {  				var rowCount = 0, -					timingOffset = perf.timing.navigationStart; -				function addRow(stat) { +					timingOffset = perf.timing.navigationStart, +					timingEnd = perf.timing.loadEventEnd; +				var totalTime = timingEnd - timingOffset; +				console.log(timingOffset, timingEnd, totalTime); +				function getLeft(stat) { +					return ((perf.timing[stat] - timingOffset) / (totalTime)) * 100.0; +				} +				function getCSSWidth(stat, endStat) { +					var width = ((perf.timing[endStat] - perf.timing[stat]) / (totalTime)) * 100.0; +					// Calculate relative percent (same as sql panel logic) +					width = 100.0 * width / (100.0 - getLeft(stat)); +					return (width < 1) ? "2px" : width + "%"; +				} +				function addRow(stat, endStat) {  					rowCount++;  					var row = document.createElement('tr'), -					    keyCell = document.createElement('td'), +						keyCell = document.createElement('td'), +						timelineCell = document.createElement('td'),  						valueCell = document.createElement('td');  					row.className = (rowCount % 2) ? 'djDebugOdd' : 'djDebugEven'; -					keyCell.innerHTML = stat; -					valueCell.innerHTML = (perf.timing[stat] - timingOffset) + " msec"; +					timelineCell.className = 'timeline'; +					if (endStat) { +						// Render a start through end bar +						keyCell.innerHTML = stat.replace('Start', '');; +						timelineCell.innerHTML = '<div class="djDebugTimeline"><div class="djDebugLineChart" style="left:' + getLeft(stat) + '%;"><strong style="width:' + getCSSWidth(stat, endStat) + ';"> </strong></div></div>'; +						valueCell.innerHTML = (perf.timing[stat] - timingOffset) + ' (+' + (perf.timing[endStat] - perf.timing[stat]) + ')'; +					} else { +						// Render a point in time +						keyCell.innerHTML = stat; +						timelineCell.innerHTML = '<div class="djDebugTimeline"><div class="djDebugLineChart" style="left:' + getLeft(stat) + '%;"><strong style="width:2px;"> </strong></div></div>'; +						valueCell.innerHTML = (perf.timing[stat] - timingOffset); +					}  					row.appendChild(keyCell); +					row.appendChild(timelineCell);  					row.appendChild(valueCell);  					d.getElementById('djDebugBrowserTimingTableBody').appendChild(row);  				} -				addRow('requestStart'); -				addRow('responseStart'); -				addRow('responseEnd'); -				addRow('domLoading'); +				// This is a reasonably complete and ordered set of timing periods (2 params) and events (1 param) +				addRow('domainLookupStart', 'domainLookupEnd'); +				addRow('connectStart', 'connectEnd'); +				addRow('requestStart', 'responseEnd') // There is no requestStart +				addRow('responseStart', 'responseEnd'); +				addRow('domLoading', 'domComplete'); // Spans the events below  				addRow('domInteractive'); -				addRow('domComplete'); -				addRow('loadEventStart'); -				addRow('loadEventEnd'); +				addRow('domContentLoadedEventStart', 'domContentLoadedEventEnd'); +				addRow('loadEventStart', 'loadEventEnd');  				d.getElementById('djDebugBrowserTiming').style.display = "block";  			}  		}  | 
