forp 是一个轻量级的 PHP 扩展,提供 PHP 配置文件数据。
总结的特性 :
PHP7 编译时要使用(–enable-dtrace)
PHP7使 用时需要设置环境变量(export USE_ZEND_DTRACE=1)
测量的时间和每个函数分配的内存
CPU 使用率
函数调用的文件和行号
输出为谷歌的跟踪事件格式
标题的功能
分组函数
别名的功能(用于匿名函数)
forp 是非侵入性的,它提供了 PHP 注释来完成工作。
Example :
<?php // first thing to do, enable forp profiler forp_start(); // here, our PHP code we want to profile function foo() { echo "Hello world !\n"; }; foo(); // stop forp buffering forp_end(); // get the stack as an array $profileStack = forp_dump(); print_r($profileStack);
Result :
Hello world ! Array ( [utime] => 0 [stime] => 0 [stack] => Array ( [0] => Array ( [file] => /home/anthony/phpsrc/php-5.3.8/ext/forp/forp.php [function] => {main} [usec] => 94 [pusec] => 6 [bytes] => 524 [level] => 0 ) [1] => Array ( [file] => /home/anthony/phpsrc/php-5.3.8/ext/forp/forp.php [function] => foo [lineno] => 10 [usec] => 9 [pusec] => 6 [bytes] => 120 [level] => 1 [parent] => 0 ) ) )