-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Currently it's hard to do profiling. I want to summarize it here and then look for a simple solution:
Add the following containers:
xhprof:
network_mode: traefik_default
image: wodby/xhprof:$XHPROF_TAG
container_name: "${PROJECT_NAME}_xhprof"
restart: always
volumes:
- ./files:/mnt/files
labels:
- 'traefik.frontend.rule=Host:${PROJECT_NAME}.xhprof.localhost'
xhprof_viewer:
network_mode: traefik_default
image: "jeromebreton/xhprof-simple-viewer:latest"
container_name: "${PROJECT_NAME}_xhprof_viewer"
restart: always
volumes:
- ./files/private/xhprof:/traces
labels:
- 'traefik.frontend.rule=Host:${PROJECT_NAME}.xhprofv.localhost'
In the PHP container:
1- add the following variable:
PHP_XHPROF: 1
2- add the following volume:
- ./files:/mnt/files
In the code where you 'd like to profile, do:
// Start profiling.
if (extension_loaded('xhprof')) {
xhprof_enable(XHPROF_FLAGS_MEMORY | XHPROF_FLAGS_CPU);
}
// ..... code to profile ..........
// Store profile.
if (extension_loaded('xhprof')) {
$data = xhprof_disable();
$xhprof_out = '/mnt/files/private/xhprof';
if (!file_exists($xhprof_out)) {
mkdir($xhprof_out);
}
file_put_contents(sprintf('%s/%s.%s.xhprof', $xhprof_out, uniqid(), 'web'), serialize($data));
}
After running the code, traces will be generated at /files/private/xhprof
and they can be viewed at:
http://PROJECT_NAME.xhprofv.localhost/index.php?run=
For some reason, the "xhprof" container is not rendering the callgraph using correct unicodes:
Metadata
Metadata
Assignees
Labels
No labels