getInstance() public static method

public static getInstance ( ) : Singleton
return Singleton instance of the filehandler
Esempio n. 1
0
     $filename = Webgrind_Config::storageDir() . $dataFile . '-' . $showFraction . Webgrind_Config::$preprocessedSuffix . '.' . Webgrind_Config::$graphImageType;
     if (!file_exists($filename)) {
         shell_exec(Webgrind_Config::$pythonExecutable . ' library/gprof2dot.py -n ' . $showFraction . ' -f callgrind ' . Webgrind_Config::xdebugOutputDir() . '' . $dataFile . ' | ' . Webgrind_Config::$dotExecutable . ' -T' . Webgrind_Config::$graphImageType . ' -o ' . $filename);
     }
     readfile($filename);
     break;
 case 'version_info':
     $response = @file_get_contents('http://jokke.dk/webgrindupdate.json?version=' . Webgrind_Config::$webgrindVersion);
     echo $response;
     break;
 case 'download_grind':
     if (!get('grind')) {
         echo "No download specified...";
     }
     $file = get('grind');
     $fh = Webgrind_FileHandler::getInstance();
     $traceList = $fh->getTraceList();
     $isTrace = false;
     foreach ($traceList as $trace) {
         if ($trace['filename'] == $file) {
             $isTrace = true;
         }
     }
     if (!$isTrace || !file_exists(Webgrind_Config::xdebugOutputDir() . $file)) {
         echo "Grind file not detected...";
         break;
     }
     header('Content-Type: text/plain');
     header('Content-Disposition: attachment; filename="' . $file . '"');
     readfile(Webgrind_Config::xdebugOutputDir() . $file);
     break;
Esempio n. 2
0
    			} else if(!is_readable($file)){
    				$message = $file.' is not readable.';
    			} else if(is_dir($file)){
    				$message = $file.' is a directory.';
    			} 		
    		} else {
    			$message = 'No file to view';
    		}
    		require 'templates/fileviewer.phtml';
	
    	break;
		case 'function_graph':
			$dataFile = get('dataFile');
			$showFraction = 100 - intval(get('showFraction') * 100);
			if($dataFile == '0'){
				$files = Webgrind_FileHandler::getInstance()->getTraceList();
				$dataFile = $files[0]['filename'];
			}
            header("Content-Type: image/png");
            $filename = Webgrind_Config::storageDir().$dataFile.'-'.$showFraction.Webgrind_Config::$preprocessedSuffix.'.png';
		    if (!file_exists($filename)) {
			    $imageData = shell_exec(Webgrind_Config::$pythonExecutable.' library/gprof2dot.py -n '.$showFraction.' -f callgrind '.Webgrind_Config::xdebugOutputDir().''.$dataFile.' | '.Webgrind_Config::$dotExecutable.' -Tpng');
			    file_put_contents($filename, $imageData);
			}
			readfile($filename);
		break;
    	case 'version_info':
    		$response = @file_get_contents('http://jokke.dk/webgrindupdate.json?version='.Webgrind_Config::$webgrindVersion);
    		echo $response;
    	break;
    	default:
Esempio n. 3
0
         $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(Webgrind_Config::$dateFormat, filemtime(Webgrind_Config::xdebugOutputDir() . $dataFile));
     echo json_encode($result);
     break;
 case 'callinfo_list':
     $reader = Webgrind_FileHandler::getInstance()->getTraceReader(get('file'), get('costFormat', Webgrind_Config::$defaultCostformat));
     $functionNr = get('functionNr');
     $function = $reader->getFunctionInfo($functionNr);
     $result = array('calledFrom' => array(), 'subCalls' => array());
     $foundInvocations = 0;
     for ($i = 0; $i < $function['calledFromInfoCount']; $i++) {
         $invo = $reader->getCalledFromInfo($functionNr, $i);
         $foundInvocations += $invo['callCount'];
         $callerInfo = $reader->getFunctionInfo($invo['functionNr']);
         $invo['file'] = urlencode($callerInfo['file']);
         $invo['callerFunctionName'] = $callerInfo['functionName'];
         $result['calledFrom'][] = $invo;
     }
     $result['calledByHost'] = $foundInvocations < $function['invocationCount'];
     for ($i = 0; $i < $function['subCallInfoCount']; $i++) {
         $invo = $reader->getSubCallInfo($functionNr, $i);