30 changed files with 584 additions and 140 deletions
			
			
		| @ -0,0 +1,46 @@ | ||||
| #yii-debug-toolbar { | ||||
| 	position: fixed; | ||||
| 	left: 0; | ||||
| 	right: 0; | ||||
| 	bottom: 0; | ||||
| 	margin: 0; | ||||
| 	padding: 0; | ||||
| 	z-index: 1000000; | ||||
| 	font: 11px Verdana, Arial, sans-serif; | ||||
| 	text-align: left; | ||||
| 	height: 38px; | ||||
| 	border-top: 1px solid #ccc; | ||||
| 	background: rgb(237,237,237); | ||||
| 	background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2VkZWRlZCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjUzJSIgc3RvcC1jb2xvcj0iI2Y2ZjZmNiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNmZmZmZmYiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+); | ||||
| 	background: -moz-linear-gradient(top,  rgba(237,237,237,1) 0%, rgba(246,246,246,1) 53%, rgba(255,255,255,1) 100%); | ||||
| 	background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(237,237,237,1)), color-stop(53%,rgba(246,246,246,1)), color-stop(100%,rgba(255,255,255,1))); | ||||
| 	background: -webkit-linear-gradient(top,  rgba(237,237,237,1) 0%,rgba(246,246,246,1) 53%,rgba(255,255,255,1) 100%); | ||||
| 	background: -o-linear-gradient(top,  rgba(237,237,237,1) 0%,rgba(246,246,246,1) 53%,rgba(255,255,255,1) 100%); | ||||
| 	background: -ms-linear-gradient(top,  rgba(237,237,237,1) 0%,rgba(246,246,246,1) 53%,rgba(255,255,255,1) 100%); | ||||
| 	background: linear-gradient(to bottom,  rgba(237,237,237,1) 0%,rgba(246,246,246,1) 53%,rgba(255,255,255,1) 100%); | ||||
| 	filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ededed', endColorstr='#ffffff',GradientType=0 ); | ||||
| } | ||||
| 
 | ||||
| .yii-debug-toolbar-block { | ||||
| 	float: left; | ||||
| 	margin: 0; | ||||
| 	border-right: 1px solid #e4e4e4; | ||||
| 	padding: 4px 8px; | ||||
| 	line-height: 32px; | ||||
| } | ||||
| 
 | ||||
| .yii-debug-toolbar-block a { | ||||
| 	text-decoration: none; | ||||
| 	color: black !important; | ||||
| } | ||||
| 
 | ||||
| .yii-debug-toolbar-block span { | ||||
| } | ||||
| 
 | ||||
| .yii-debug-toolbar-block img { | ||||
| 	vertical-align: middle; | ||||
| } | ||||
| 
 | ||||
| span.indent { | ||||
| 	color: #ccc; | ||||
| } | ||||
									
										
											File diff suppressed because one or more lines are too long
										
									
								
							
						| @ -0,0 +1,21 @@ | ||||
| <?php | ||||
| /** | ||||
|  * @link http://www.yiiframework.com/ | ||||
|  * @copyright Copyright (c) 2008 Yii Software LLC | ||||
|  * @license http://www.yiiframework.com/license/ | ||||
|  */ | ||||
| 
 | ||||
| namespace yii\debug\panels; | ||||
| use yii\debug\Panel; | ||||
| 
 | ||||
| /** | ||||
|  * @author Qiang Xue <qiang.xue@gmail.com> | ||||
|  * @since 2.0 | ||||
|  */ | ||||
| class DbPanel extends Panel | ||||
| { | ||||
| 	public function getName() | ||||
| 	{ | ||||
| 		return 'Database'; | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1,85 @@ | ||||
| <?php | ||||
| /** | ||||
|  * @link http://www.yiiframework.com/ | ||||
|  * @copyright Copyright (c) 2008 Yii Software LLC | ||||
|  * @license http://www.yiiframework.com/license/ | ||||
|  */ | ||||
| 
 | ||||
| namespace yii\debug\panels; | ||||
| 
 | ||||
| use Yii; | ||||
| use yii\debug\Panel; | ||||
| use yii\helpers\Html; | ||||
| use yii\log\Logger; | ||||
| 
 | ||||
| /** | ||||
|  * @author Qiang Xue <qiang.xue@gmail.com> | ||||
|  * @since 2.0 | ||||
|  */ | ||||
| class ProfilingPanel extends Panel | ||||
| { | ||||
| 	public function getName() | ||||
| 	{ | ||||
| 		return 'Profiling'; | ||||
| 	} | ||||
| 
 | ||||
| 	public function getDetail() | ||||
| 	{ | ||||
| 		$messages = $this->data['messages']; | ||||
| 		$timings = array(); | ||||
| 		$stack = array(); | ||||
| 		foreach ($messages as $i => $log) { | ||||
| 			list($token, $level, $category, $timestamp) = $log; | ||||
| 			$log[4] = $i; | ||||
| 			if ($level == Logger::LEVEL_PROFILE_BEGIN) { | ||||
| 				$stack[] = $log; | ||||
| 			} elseif ($level == Logger::LEVEL_PROFILE_END) { | ||||
| 				if (($last = array_pop($stack)) !== null && $last[0] === $token) { | ||||
| 					$timings[$last[4]] = array(count($stack), $token, $category, $timestamp - $last[3]); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		$now = microtime(true); | ||||
| 		while (($last = array_pop($stack)) !== null) { | ||||
| 			$delta = $now - $last[3]; | ||||
| 			$timings[$last[4]] = array(count($stack), $last[0], $last[2], $delta); | ||||
| 		} | ||||
| 		ksort($timings); | ||||
| 
 | ||||
| 		$rows = array(); | ||||
| 		foreach ($timings as $timing) { | ||||
| 			$time = sprintf('%.1f ms', $timing[3] * 1000); | ||||
| 			$procedure = str_repeat('<span class="indent">→</span>', $timing[0]) . Html::encode($timing[1]); | ||||
| 			$category = Html::encode($timing[2]); | ||||
| 			$rows[] = "<tr><td style=\"width: 80px;\">$time</td><td style=\"width: 220px;\">$category</td><td>$procedure</td>"; | ||||
| 		} | ||||
| 		$rows = implode("\n", $rows); | ||||
| 
 | ||||
| 		return <<<EOD | ||||
| <h1>Performance Profiling</h1> | ||||
| 
 | ||||
| <table class="table table-condensed table-bordered table-striped table-hover" style="table-layout: fixed;"> | ||||
| <thead> | ||||
| <tr> | ||||
| 	<th style="width: 80px;">Time</th> | ||||
| 	<th style="width: 220px;">Category</th> | ||||
| 	<th>Procedure</th> | ||||
| </tr> | ||||
| </thead> | ||||
| <tbody> | ||||
| $rows | ||||
| </tbody> | ||||
| </table> | ||||
| EOD; | ||||
| 	} | ||||
| 
 | ||||
| 	public function save() | ||||
| 	{ | ||||
| 		$target = $this->module->logTarget; | ||||
| 		$messages = $target->filterMessages($target->messages, Logger::LEVEL_PROFILE); | ||||
| 		return array( | ||||
| 			'messages' => $messages, | ||||
| 		); | ||||
| 	} | ||||
| } | ||||
					Loading…
					
					
				
		Reference in new issue