コード例 #1
0
ファイル: webgrind.php プロジェクト: phpclub/webgrind
 /**
  * Writable dir for information storage
  */
 public static function storageDir()
 {
     $storage = Kohana::config('webgrind.storageDir');
     if (!empty($storage)) {
         return realpath($storage) . '/';
     }
     if (!function_exists('sys_get_temp_dir') || !is_writable(sys_get_temp_dir())) {
         # use xdebug setting
         return webgrind::xdebugOutputDir();
     }
     return realpath(sys_get_temp_dir()) . '/';
 }
コード例 #2
0
ファイル: webgrind.php プロジェクト: phpclub/webgrind
 * Reuse the same window when profiling. Will not open multiple webgrind windows.
 *
 * DEFAULT: TRUE
 */
$config['reuse_window'] = TRUE;
/* WEBGRIND VENDOR OPTIONS */
$config['checkVersion'] = false;
$config['hideWebgrindProfiles'] = true;
/**
* Writable dir for information storage.
* If empty, will use system tmp folder or xdebug tmp
*/
$config['storageDir'] = '';
$config['profilerDir'] = '/tmp';
/**
* Suffix for preprocessed files
*/
$config['preprocessedSuffix'] = '.webgrind';
$config['defaultTimezone'] = 'Europe/Copenhagen';
$config['dateFormat'] = 'Y-m-d H:i:s';
$config['defaultCostformat'] = 'percent';
// 'percent', 'usec' or 'msec'
$config['defaultFunctionPercentage'] = 90;
$config['defaultHideInternalFunctions'] = false;
/**
* sprintf compatible format for generating links to source files. 
* %1$s will be replaced by the full path name of the file
* %2$d will be replaced by the linenumber
*/
$config['fileUrlFormat'] = webgrind::url() . '?op=fileviewer&file=%1$s&line=%2$d';
// Built in fileviewer
コード例 #3
0
ファイル: webgrind_index.php プロジェクト: phpclub/webgrind
"><?php 
    echo $trace['invokeUrl'];
    ?>
 (<?php 
    echo $trace['filename'];
    ?>
) [<?php 
    echo $trace['filesize'];
    ?>
]</option>
            			<?php 
}
?>
            		</select>
        			<img class="list_reload" src="<?php 
echo webgrind::img("reload.png");
?>
" onclick="reloadFilelist()">
            	</div>
            	<div style="float:right">
            		<label style="margin:0 5px">Show</label>
            		<select id="showFraction" name="showFraction">
            			<?php 
for ($i = 100; $i > 0; $i -= 10) {
    ?>
            			<option value="<?php 
    echo $i / 100;
    ?>
" <?php 
    if ($i == Kohana::config('webgrind.defaultFunctionPercentage')) {
        ?>
コード例 #4
0
ファイル: webgrind.php プロジェクト: phpclub/webgrind
 public function function_list()
 {
     $dataFile = webgrind::get('dataFile');
     if ($dataFile == '0') {
         $files = Webgrind_Filehandler::getInstance()->getTraceList();
         $dataFile = $files[0]['filename'];
     }
     $reader = Webgrind_Filehandler::getInstance()->getTraceReader($dataFile, webgrind::get('costFormat', Kohana::config('webgrind.defaultCostformat')));
     $functions = array();
     $shownTotal = 0;
     $breakdown = array('internal' => 0, 'user' => 0, 'class' => 0, 'include' => 0);
     for ($i = 0; $i < $reader->getFunctionCount(); $i++) {
         $functionInfo = $reader->getFunctionInfo($i);
         if (false !== strpos($functionInfo['functionName'], 'php::')) {
             $breakdown['internal'] += $functionInfo['summedSelfCost'];
             $humanKind = 'internal';
             $kind = 'blue';
         } elseif (false !== strpos($functionInfo['functionName'], 'require_once::') || false !== strpos($functionInfo['functionName'], 'require::') || false !== strpos($functionInfo['functionName'], 'include_once::') || false !== strpos($functionInfo['functionName'], 'include::')) {
             $breakdown['include'] += $functionInfo['summedSelfCost'];
             $humanKind = 'include';
             $kind = 'grey';
         } else {
             if (false !== strpos($functionInfo['functionName'], '->') || false !== strpos($functionInfo['functionName'], '::')) {
                 $breakdown['class'] += $functionInfo['summedSelfCost'];
                 $humanKind = 'class';
                 $kind = 'green';
             } else {
                 $breakdown['user'] += $functionInfo['summedSelfCost'];
                 $humanKind = 'procedural';
                 $kind = 'orange';
             }
         }
         if (!(int) webgrind::get('hideInternals', 0) || strpos($functionInfo['functionName'], 'php::') === false) {
             $shownTotal += $functionInfo['summedSelfCost'];
             $functions[$i] = $functionInfo;
             $functions[$i]['nr'] = $i;
             $functions[$i]['kind'] = $kind;
             $functions[$i]['humanKind'] = $humanKind;
         }
     }
     usort($functions, array('webgrind', 'cost_cmp'));
     $remainingCost = $shownTotal * webgrind::get('showFraction');
     $result['functions'] = array();
     foreach ($functions as $function) {
         $remainingCost -= $function['summedSelfCost'];
         $result['functions'][] = $function;
         if ($remainingCost < 0) {
             break;
         }
     }
     $result['summedInvocationCount'] = $reader->getFunctionCount();
     $result['summedRunTime'] = $reader->formatCost($reader->getHeader('summary'), 'msec');
     $result['dataFile'] = $dataFile;
     $result['invokeUrl'] = $reader->getHeader('cmd');
     $result['runs'] = $reader->getHeader('runs');
     $result['breakdown'] = $breakdown;
     $result['mtime'] = date(Kohana::config('webgrind.dateFormat'), filemtime(webgrind::xdebugOutputDir() . $dataFile));
     echo json_encode($result);
 }
コード例 #5
0
 /**
  * Get a trace reader for the specific file.
  * 
  * If the file has not been preprocessed yet this will be done first.
  *
  * @param string File to read
  * @param Cost format for the reader
  * @return Webgrind_Reader Reader for $file
  */
 public function getTraceReader($file, $costFormat)
 {
     $prepFile = webgrind::storageDir() . $file . $this->suffix;
     try {
         $r = new Webgrind_Reader($prepFile, $costFormat);
     } catch (Exception $e) {
         // Preprocessed file does not exist or other error
         Webgrind_Preprocessor::parse(webgrind::xdebugOutputDir() . $file, $prepFile);
         $r = new Webgrind_Reader($prepFile, $costFormat);
     }
     return $r;
 }