Beispiel #1
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_Config::storageDir() . $file . Webgrind_Config::$preprocessedSuffix;
     try {
         $r = new Webgrind_Reader($prepFile, $costFormat);
     } catch (Exception $e) {
         // Preprocessed file does not exist or other error
         Webgrind_Preprocessor::parse(Webgrind_Config::xdebugOutputDir() . $file, $prepFile);
         $r = new Webgrind_Reader($prepFile, $costFormat);
     }
     return $r;
 }
Beispiel #2
0
            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:
            $welcome = '';
    	    if (!file_exists(Webgrind_Config::storageDir()) || !is_writable(Webgrind_Config::storageDir())) {
    	        $welcome .= 'Webgrind $storageDir does not exist or is not writeable: <code>'.Webgrind_Config::storageDir().'</code><br>';
    	    }
    	    if (!file_exists(Webgrind_Config::xdebugOutputDir()) || !is_readable(Webgrind_Config::xdebugOutputDir())) {
    	        $welcome .= 'Webgrind $profilerDir does not exist or is not readable: <code>'.Webgrind_Config::xdebugOutputDir().'</code><br>';
    	    }
    	    
    	    if ($welcome == '') {
        	    $welcome = 'Select a cachegrind file above<br>(looking in <code>'.Webgrind_Config::xdebugOutputDir().'</code> for files matching <code>'.Webgrind_Config::xdebugOutputFormat().'</code>)';
    	    }
    		require 'templates/index.phtml';
    }
} catch (Exception $e) {
    echo json_encode(array('error' => $e->getMessage().'<br>'.$e->getFile().', line '.$e->getLine()));
    return;
}