PHP8 xhprof_enable — 啟動 xhprof 性能分析器

2023-10-16 14:44 更新

(PECL xhprof >= 0.9.0)

xhprof_enable — 啟動 xhprof 性能分析器

說明

xhprof_enable(int $flags = 0, array $options = ?): void

啟動 xhprof 進行性能分析。

參數(shù)

flags

分析添加額外信息的可選標(biāo)記。 關(guān)于此標(biāo)記的更多信息參見 XHprof 常量,例如, XHPROF_FLAGS_MEMORY 可以開啟內(nèi)存的分析。

options

array 的可選選項,就是通過傳遞 'ignored_functions' 選項來忽略性能分析中的某些函數(shù)。

返回值

null

更新日志

版本 說明
PECL xhprof 0.9.2 添加可選的 options 參數(shù)。

示例

示例 #1 xhprof_enable() 示例

<?php
// 1. elapsed time + memory + CPU profiling; and ignore built-in (internal) functions
xhprof_enable(XHPROF_FLAGS_NO_BUILTINS | XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY);

// 2. elapsed time profiling; ignore call_user_func* during profiling
xhprof_enable(
0,
array('ignored_functions' => array('call_user_func',
'call_user_func_array')));

// 3. elapsed time + memory profiling; ignore call_user_func* during profiling
xhprof_enable(
XHPROF_FLAGS_MEMORY,
array('ignored_functions' => array('call_user_func',
'call_user_func_array')));
?>

參見

  • xhprof_disable() - 停止 xhprof 分析器
  • xhprof_sample_enable() - 以采樣模式啟動 XHProf 性能分析
  • memory_get_usage() - 返回分配給 PHP 的內(nèi)存量
  • getrusage() - 獲取當(dāng)前資源使用狀況


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號