forked from leftypol/leftypol
Add profile.php for profiling
This commit is contained in:
parent
54feeba2da
commit
0b746c4ec6
1 changed files with 21 additions and 0 deletions
21
inc/profile.php
Normal file
21
inc/profile.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
// From https://www.mediawiki.org/wiki/Excimer
|
||||
// Inject with `auto_prepend_file` in php.ini
|
||||
|
||||
if (extension_loaded("excimer")) {
|
||||
error_log("Profiler started", 0);
|
||||
|
||||
static $prof; // Keep object until the end of the request
|
||||
$prof = new ExcimerProfiler();
|
||||
$prof->setEventType(EXCIMER_REAL);
|
||||
$prof->setPeriod(5); // every N seconds
|
||||
$prof->setMaxDepth(250);
|
||||
|
||||
$prof->setFlushCallback(function ($log) {
|
||||
error_log("Logged profile", 0);
|
||||
file_put_contents('/tmp/profles-ramfs/excimer-traces.log', $log->formatCollapsed(), FILE_APPEND | LOCK_EX);
|
||||
}, 1);
|
||||
$prof->start();
|
||||
} else {
|
||||
error_log("Profiler code injected, but no excimer extension installed");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue