forked from leftypol/leftypol
Merge pull request 'Add the excimer profier injactable file' (#148) from profile-excimer into config
Reviewed-on: https://git.leftypol.org/leftypol/leftypol/pulls/148
This commit is contained in:
commit
466d569d74
2 changed files with 23 additions and 0 deletions
|
@ -47,10 +47,12 @@ RUN apk add --no-cache \
|
|||
&& pecl install -o -f igbinary \
|
||||
&& pecl install redis \
|
||||
&& pecl install imagick \
|
||||
&& pecl install excimer \
|
||||
&& docker-php-ext-enable \
|
||||
igbinary \
|
||||
redis \
|
||||
imagick \
|
||||
excimer \
|
||||
&& apk del \
|
||||
zlib-dev \
|
||||
libpng-dev \
|
||||
|
|
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