Commit 27d8873a authored by romanb's avatar romanb

[2.0] Added jpgraph.php script that can be used to visualize logs of phpunit...

[2.0] Added jpgraph.php script that can be used to visualize logs of phpunit test runs with graphs using jpgraph. The graphs show the performance of tests over the revisions.
parent e4e1291b
<?php
// If you dont have jpgraph, you need to download it from:
// http://www.aditus.nu/jpgraph/jpdownload.php
$jpgraphPath = '../lib/jpgraph-3.0.3/src'; // put the path to your jpgraph install here
// ------------------------------------------
require_once "$jpgraphPath/jpgraph.php";
require_once "$jpgraphPath/jpgraph_line.php";
$logsPath = 'logs/';
$revisions = array();
$graphs = array();
if (isset($_POST['test'])) {
list($testsuite, $testcase) = explode('#', $_POST['test']);
}
$items = scandir($logsPath);
foreach ($items as $item) {
if ($item[0] != '.') {
$revisions[] = $item;
}
}
foreach ($revisions as $rev) {
$xml = simplexml_load_file($logsPath . $rev . '/log.xml');
foreach ($xml->testsuite as $suite) {
foreach ($suite->testcase as $test) {
$name = (string)$suite['name'] . '#' . (string)$test['name'];
$graphs[$name][] = (double)$test['time'];
}
}
}
if (isset($testsuite) && isset($testcase)) {
$graphName = $testsuite . '#' . $testcase;
$graphData = $graphs[$graphName];
// Create the graph. These two calls are always required
$graph = new Graph(650,250);
//$graph->SetScale('intint');
$graph->SetScale('textlin');
$graph->yaxis->scale->SetAutoMin(0);
$graph->title->Set($testsuite);
$graph->subtitle->Set($testcase);
$graph->xaxis->title->Set('revision');
$graph->yaxis->title->Set('seconds');
$graph->SetMargin(100, 100, 50, 50);
// Create the linear plot
$lineplot = new LinePlot($graphData);
$lineplot->SetColor('blue');
$graph->xaxis->SetTickLabels($revisions);
// Add the plot to the graph
$graph->Add($lineplot);
// Display the graph
$graph->Stroke();
} else {
echo '<html><head></head><body>';
echo 'Pick a test and click "show":<br/>';
echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">';
echo '<select name="test">';
foreach ($graphs as $name => $data) {
echo '<option value="' . $name . '">' . $name . '</option>';
}
echo '</select>';
echo '<button type="submit">Show</button>';
echo '</form>';
echo '</body></html>';
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment