Skip to content

Commit

Permalink
[NEW] Add ability to generate call graph
Browse files Browse the repository at this point in the history
Use gprof2dot.py to generate call graphs
  • Loading branch information
yannooo committed Feb 1, 2011
1 parent 4a1eee1 commit bf71343
Show file tree
Hide file tree
Showing 4 changed files with 2,804 additions and 0 deletions.
23 changes: 23 additions & 0 deletions config.php
Expand Up @@ -29,6 +29,9 @@ class Webgrind_Config extends Webgrind_MasterConfig {
static $defaultCostformat = 'percent'; // 'percent', 'usec' or 'msec'
static $defaultFunctionPercentage = 90;
static $defaultHideInternalFunctions = false;

static $pythonExecutable = '';
static $dotExecutable = '';

/**
* sprintf compatible format for generating links to source files.
Expand Down Expand Up @@ -90,4 +93,24 @@ static function storageDir() {
}
return realpath(sys_get_temp_dir()).'/';
}

/**
* Path to graphviz dot executable
*/
static function dotExecutable() {
if (!empty(Webgrind_Config::$dotExecutable))
return realpath(Webgrind_Config::$dotExecutable);

return '/usr/bin/dot';
}

/**
* Path to python executable
*/
static function pythonExecutable() {
if (!empty(Webgrind_Config::$pythonExecutable))
return realpath(Webgrind_Config::$pythonExecutable);

return '/usr/bin/python';
}
}
10 changes: 10 additions & 0 deletions index.php
Expand Up @@ -134,6 +134,16 @@ class Webgrind_MasterConfig
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");
passthru(Webgrind_Config::pythonExecutable().' library/gprof2dot.py -n '.$showFraction.' -f callgrind '.Webgrind_Config::xdebugOutputDir().''.$dataFile.' | '.Webgrind_Config::dotExecutable().' -Tpng');
break;
case 'version_info':
$response = @file_get_contents('http://jokke.dk/webgrindupdate.json?version='.Webgrind_Config::$webgrindVersion);
echo $response;
Expand Down

0 comments on commit bf71343

Please sign in to comment.