php-spx icon indicating copy to clipboard operation
php-spx copied to clipboard

Closure names aliased & ambiguous in reports

Open NoiseByNorthwest opened this issue 3 years ago • 3 comments

A closure name, as returned/generated by the Zend Engine, follows this pattern \Foo\Bar{closure} (when created by a class method) where Foo is the namespace and Bar the class.

Thus if the class's methods create several closures at several places then they will appear as a single closure and theirs stats will be merged.

Moreover a closure name does not bring any information about where it is created.

NoiseByNorthwest avatar Jul 25 '21 21:07 NoiseByNorthwest

I just ran into this issue as well. I think it would be good if SPX could append the line numbers of the closure, for example \Foo\Bar{closure}150-157

This way it's easy to identify exactly which closure in a given class was called.

mpociot avatar Jun 07 '23 11:06 mpociot

Yes, we need something like this, but the line range will still fail with short arrow functions defined on the same line. Do you know how other profilers handle this case ?

NoiseByNorthwest avatar Jun 08 '23 07:06 NoiseByNorthwest

My initial goal was to build a callgraph out of the data that SPX collects - similar to Blackfire.io

Here's a demo: https://demo.blackfire.io/profiles/d5f83d3d-ba09-43ee-9e33-51677cf9c988/graph?settings%5Bdimension%5D=wt&settings%5Bdisplay%5D=landscape&settings%5BtabPane%5D=nodes&selected=&callname=main()&constraintDoc=

They add the line numbers as the suffix - and in some cases also have some "ID"/hash, but I don't know how that gets calculated.

mpociot avatar Jun 08 '23 07:06 mpociot