Permalink
Browse files

[NEW] Call graphs are cached

[CHANGED] Callgraph configuration cleanup
  • Loading branch information...
1 parent 48d973e commit 6a1ae891b207c7f64c8f5fb7d3940d6595c700a9 @jokkedk committed Mar 1, 2011
Showing with 25 additions and 33 deletions.
  1. +9 −22 config.php
  2. +15 −10 index.php
  3. +1 −1 templates/index.phtml
View
@@ -30,8 +30,15 @@ class Webgrind_Config extends Webgrind_MasterConfig {
static $defaultFunctionPercentage = 90;
static $defaultHideInternalFunctions = false;
- static $pythonExecutable = '';
- static $dotExecutable = '';
+ /**
+ * Path to python executable
+ */
+ static $pythonExecutable = '/usr/bin/python';
+
+ /**
+ * Path to graphviz dot executable
+ */
+ static $dotExecutable = '/usr/local/bin/dot';
/**
* sprintf compatible format for generating links to source files.
@@ -93,24 +100,4 @@ 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';
- }
}
View
@@ -134,16 +134,21 @@ 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 '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.'.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;
View
@@ -336,7 +336,7 @@
<div style="float:right;">
<div id="breakdown" style="margin-bottom:5px;width:320px;height:20px"></div>
<span id="invocation_sum"></span> different functions called in <span id="runtime_sum"></span> milliseconds (<span id="runs"></span> runs, <span id="shown_sum"></span> shown)
- <div><a href="javascript:showCallGraph()">Show Call Graph</a></div>
+ <div><a href="javascript:showCallGraph()">Show Call Graph</a></div>
</div>
<div style="clear:both"></div>
Filter: <input type="text" style="width:150px" id="callfilter"> (regex too)

0 comments on commit 6a1ae89

Please sign in to comment.