R
R
Roman Vykhvatnyuk2016-11-30 00:11:50
PHP
Roman Vykhvatnyuk, 2016-11-30 00:11:50

Why doesn't xprof display memory usage when passing XHPROF_FLAGS_MEMORY?

Used xprof on php 5.6 - worked mostly fine. We switched to php7 - there is no official support for PHP 7 from xhprof yet, so we used a third-party fork - https://andymarrel.eu/programming/xhprof-php-7 - connected, it works, but only displays "Total Incl. Wall Time" and " Number of Function Calls" - does not show memory usage. Tested in the console - without any add-ons:

<?php
function bar($x) {
  if ($x > 0) {
    bar($x - 1);
  }
}
function foo() {
  for ($idx = 0; $idx < 2; $idx++) {
    bar($idx);
    $x = strlen("abc");
  }
}
// start profiling
xhprof_enable();
// run program
foo();
// stop profiler
$xhprof_data = xhprof_disable();
// display raw xhprof data for the profiler run
print_r($xhprof_data);

The result is correct like:
Array
(
    [foo==>bar] => Array
        (
            [ct] => 2
            [wt] => 23
        )
    [bar==>[email protected]] => Array
        (
            [ct] => 1
            [wt] => 2
        )
    [main()==>foo] => Array
        (
            [ct] => 1
            [wt] => 58
        )
    [main()==>xhprof_disable] => Array
        (
            [ct] => 1
            [wt] => 0
        )
    [main()] => Array
        (
            [ct] => 1
            [wt] => 71
        )
)

But after passing XHPROF_FLAGS_MEMORY or XHPROF_FLAGS_CPU to xhprof_enable() nothing changes.
Is this a problem of the seven or something else?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2019-05-30
Semenov

Use this fork for 7k: https://tideways.com/profiler/xhprof-for-php7
enable memory and cpu like this:
tideways_xhprof_enable( TIDEWAYS_XHPROF_FLAGS_MEMORY | TIDEWAYS_XHPROF_FLAGS_CPU );
Additional info: https://support.tideways.com/article/185-tideways-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question