-
Notifications
You must be signed in to change notification settings - Fork 1
/
prepend_v5.php
40 lines (34 loc) · 1.49 KB
/
prepend_v5.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
register_shutdown_function(
function () {
register_shutdown_function(function () {
$data = tideways_xhprof_disable();
echo "TidewaysXHPROF: ", phpversion("tideways_xhprof"), ", PHP: ", phpversion(), "\n";
echo 'Nodes in report: ' . count($data) . "\n";
$name = getenv('REPORT');
if (empty($name)) {
$name = 'xhprof_report.' . microtime(1) . '.serialized';
}
echo 'Saving report to ' . $name, "\n";
file_put_contents('/code/' . $name,
'.json' === substr($name, -5) ? json_encode($data) : serialize($data));
if (getenv('SVG')) {
include_once "/utils/callgraph_utils.php";
include_once "/utils/xhprof_lib.php";
include_once "/utils/xhprof_runs.php";
echo "Generating dot script\n";
$threshold = 0;
if (count($data) > 1000) {
$threshold = 0.001;
}
$script = xhprof_generate_dot_script($data, $threshold, null, null, null, null);
echo "Generating dot image\n";
$content = xhprof_generate_image_by_dot($script, 'svg');
echo 'Saving graph to ' . $name . '.svg', "\n";
file_put_contents('/code/' . $name . '.svg',
$content);
}
});
}
);
tideways_xhprof_enable(TIDEWAYS_XHPROF_FLAGS_MEMORY | TIDEWAYS_XHPROF_FLAGS_CPU);