<?php
if ( extension_loaded( 'excimer' ) && isset( $_GET['forceflame'] ) ) {
$prof = new ExcimerProfiler();
$prof->setPeriod( 0.1 / 1000 ); // Every 0.1ms
$prof->setEventType( EXCIMER_REAL );
$prof->start();
register_shutdown_function( function () use ( $prof ) {
$prof->stop();
$title = MW_ENTRY_POINT . '.php ' . gmdate( 'Y-m-d H:i:s' ) . ' UTC';
$pipe = popen( "/usr/local/bin/flamegraph.pl --title=\"$title\" > /var/www/html/w/docs/flamegraph.svg", 'w' );
fwrite( $pipe, $prof->getLog()->formatCollapsed() );
} );
}
<?php
$title = 'UTC';
$pipe = popen( "flamegraph.pl --title=\"$title\" > /var/www/html/w/docs/flamegraph.svg", 'w' );
fwrite( $pipe, $prof->getLog()->formatCollapsed() );
The string is currently terminated after the third quote in
"foo \"$bar\" baz"instead of at the end.Source:
Pygments:
Downstream: https://www.mediawiki.org/w/index.php?title=MediaWiki-Docker/Configuration_recipes/Profiling&oldid=5148799
Minimal demo:
https://pygments.org/demo/?lexer=php&style=xcode&formatter=html&code=%3C%3Fphp%0A%24title+%3D+%27UTC%27%3B%0A%24pipe+%3D+popen%28+%22flamegraph.pl+--title%3D%5C%22%24title%5C%22+%3E+%2Fvar%2Fwww%2Fhtml%2Fw%2Fdocs%2Fflamegraph.svg%22%2C+%27w%27+%29%3B%0Afwrite%28+%24pipe%2C+%24prof-%3EgetLog%28%29-%3EformatCollapsed%28%29+%29%3B