perftools / php-profiler Goto Github PK
View Code? Open in Web Editor NEWA PHP profiling library based on XHGUI Data Collector
License: MIT License
A PHP profiling library based on XHGUI Data Collector
License: MIT License
The reason is simple, I've already used to switching to branch main
.
This will give also out impression to other developers that the project is modern and actively maintained ;)
Currently https://github.com/perftools/php-profiler/blob/main/src/Config.php will throw deprecation notices because any implementation of ArrayAccess needs to have the methods compatible.
PHP Deprecated: Return type of Xhgui\Profiler\Config::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
as an example, but all the offset functions are affected.
So as it says; either the return type must be defined or it must be noted that the return type will change
In mongo saver there's getLastProfilingId method:
that has a side-effect, that if this saver is called in the application side, the id would be re-used for multiple profilings.
I don't know if that's deliberate or not, but using other savers this functionality is not present.
Question:
Having it profiler side could overwrite (accidentally or deliberately) existing profiling. I don't think saving the same id twice will merge the results?
Having it set at the profiler side, allows the profiler to control the id value.
and if reading the importer section:
it says importing the same profile twice creates duplicate profiling, so the duplicate id sent from profiler is not overwriting other profilers? is there any point then having value re-used? set from profiler?
cc @perftools/maintainers
Can you add support for 8.1 version into your composer.json, please ?
Currently composer.json locked for
"php": "^5.3.0 || ^7.0 || ^8.0"
When using XHProf as composer package it is available after loading vendor/autoload.php .
This makes it impossible to measure the impact of vendor-loading itself
and also PHP 7.4 preloading can not be used in any way.
Creating a preload.php with essential classes could solve the problem.
Example:
When writing a package that has some file loaded via composer
{
"files": [
"foo.php"
],
}
then XHProf needs to be available before Composers autoload.php to measure its impact.
By now this can be done manually:
require_once __DIR__ . '/../vendor/perftools/php-profiler/src/Profilers/ProfilerInterface.php';
require_once __DIR__ . '/../vendor/perftools/php-profiler/src/Profilers/AbstractProfiler.php';
require_once __DIR__ . '/../vendor/perftools/php-profiler/src/Profilers/XHProf.php';
require_once __DIR__ . '/../vendor/perftools/php-profiler/src/Profilers/UProfiler.php';
require_once __DIR__ . '/../vendor/perftools/php-profiler/src/Profilers/TidewaysXHProf.php';
require_once __DIR__ . '/../vendor/perftools/php-profiler/src/Profilers/Tideways.php';
require_once __DIR__ . '/../vendor/perftools/php-profiler/src/SaverFactory.php';
require_once __DIR__ . '/../vendor/perftools/php-profiler/src/Saver/SaverInterface.php';
require_once __DIR__ . '/../vendor/perftools/php-profiler/src/Saver/UploadSaver.php';
require_once __DIR__ . '/../vendor/perftools/php-profiler/src/ProfilerFactory.php';
require_once __DIR__ . '/../vendor/perftools/php-profiler/src/ProfilingFlags.php';
require_once __DIR__ . '/../vendor/perftools/php-profiler/src/Profiler.php';
(new \Xhgui\Profiler\Profiler( /* ... */ ))->start();
require_once __DIR__ . '/../vendor/autoload.php';
But it would be nice to have a preload.php in this repo ( https://github.com/perftools/php-profiler ) that loads all classes to allow measuring of vendor autoloads.
Hi, @glensc , first of all thank you for supporting this package <3
In my project i need to exclude all $_ENV, there is few thousands of secrets.
Actualy this meta.env not used in xhgui UI.
Can we add some flag to not export this envs in ProfilingData::getProfilingData ?
Like profiler.exclude-all-env: bool
?
Or maybe check profiler.exclude-env
is true
- exclude all instead of list?
I can make PR.
PHP Fatal error: Uncaught MongoDB\Driver\Exception\InvalidArgumentException: invalid document for insert: keys cannot contain "."
/vendor/mongodb/mongodb/src/Operation/InsertOne.php:103
Why does perftools/php-profiler not support non intrusive type,such as using auto_ prepend_file to introduce the component? Thank you!
I'm running this within a php 8.1 alpine docker image and noticed that the cumulative counts are way off.
I'm using the Profiler::PROFILER_TIDEWAYS_XHPROF
profiler.
$builtIns = (int) ($_GET['xhprof_builtins'] ?? 0);
$flags = [
ProfilingFlags::CPU,
ProfilingFlags::MEMORY,
ProfilingFlags::NO_SPANS,
ProfilingFlags::NO_BUILTINS
];
if ($builtIns === 1) {
unset($flags[3]);
}
$profiler = new \Xhgui\Profiler\Profiler([
'profiler' => Profiler::PROFILER_TIDEWAYS_XHPROF,
'profiler.enable' => function () {
$queryToken = $_ENV['XHPROF_QUERY_TOKEN'] ?? null;
$incomingToken = $_GET['xhprof'] ?? null;
return !empty($queryToken) && $incomingToken === $queryToken;
},
'profiler.flags' => $flags,
'save.handler' => \Xhgui\Profiler\Profiler::SAVER_UPLOAD,
'save.handler.upload' => array(
'url' => $_ENV['XHGUI_HOST'] . '/run/import',
'timeout' => 3,
'token' => $_ENV['XHGUI_UPLOAD_TOKEN'],
),
]);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.