1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the reliforp/reli-prof package. |
5
|
|
|
* |
6
|
|
|
* (c) sji <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace Reli\Command\Converter; |
15
|
|
|
|
16
|
|
|
use Reli\Converter\Callgrind\FunctionEntry; |
17
|
|
|
use Reli\Converter\Callgrind\Profile; |
18
|
|
|
use Reli\Converter\ParsedCallTrace; |
19
|
|
|
use Reli\Converter\PhpSpyCompatibleParser; |
20
|
|
|
use Symfony\Component\Console\Command\Command; |
|
|
|
|
21
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
|
|
|
22
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
|
|
|
23
|
|
|
|
24
|
|
|
final class CallgrindCommand extends Command |
25
|
|
|
{ |
26
|
|
|
public function configure(): void |
27
|
|
|
{ |
28
|
|
|
$this->setName('converter:callgrind') |
29
|
|
|
->setDescription('convert traces to the callgrind file format') |
30
|
|
|
; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function execute(InputInterface $input, OutputInterface $output): int |
34
|
|
|
{ |
35
|
|
|
$parser = new PhpSpyCompatibleParser(); |
36
|
|
|
$output->writeln('# format callgrind'); |
37
|
|
|
$output->writeln('events: Samples'); |
38
|
|
|
$output->writeln(''); |
39
|
|
|
|
40
|
|
|
$profile = new Profile(); |
41
|
|
|
foreach ($parser->parseFile(STDIN) as $trace) { |
42
|
|
|
$profile->addTrace($trace); |
43
|
|
|
} |
44
|
|
|
foreach ($profile->functions as $function) { |
45
|
|
|
$output->writeln('fl=' . $function->file_name); |
46
|
|
|
$output->writeln('fn=' . $function->function_name); |
47
|
|
|
foreach ($function->lineno_samples as $lineno => $samples) { |
48
|
|
|
$output->writeln($lineno . ' ' . $samples); |
49
|
|
|
} |
50
|
|
|
foreach ($function->calls as $call) { |
51
|
|
|
$output->writeln('cfl=' . $call->callee->file_name); |
52
|
|
|
$output->writeln('cfn=' . $call->callee->function_name); |
53
|
|
|
// We don't know how many calls were made, only the number of samples. |
54
|
|
|
// We also don't know the start line of the callee. |
55
|
|
|
$output->writeln('calls=-1 -1'); |
56
|
|
|
$output->writeln($call->caller_lineno . ' ' . $call->samples); |
57
|
|
|
} |
58
|
|
|
$output->writeln(''); |
59
|
|
|
} |
60
|
|
|
return 0; |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths