Track memory usage of a method

后端 未结 6 2153
[愿得一人]
[愿得一人] 2021-02-20 11:58

I have yet to find an elegant solution for this. I have a class with a method I want to track the memory usage of without modifying the function:

class Example
{         


        
6条回答
  •  攒了一身酷
    2021-02-20 12:56

    It looks like it has already 'freed up' memory after the call to hello() has ended.

    What are the results when you do:

    $s = memory_get_usage();
    
    $class->hello('a');
    
    echo memory_get_peak_usage() - $s;
    

提交回复
热议问题