Xhprof分析php性能
https://windows.php.net/downloads/pecl/releases/xhprof/0.10.6/ 下载Xhprof版本

配置一个本地访问url,指向index.php,能访问即可。http://loc.oms.xhprof:9091
然后取php官网下载扩展,写在php.ini上
[xhprof]
extension=php_xhprof.dll
; directory used by default implementation of the iXHProfRuns
; interface (namely, the XHProfRuns_Default class) for storing
; XHProf runs.
xhprof.output_dir="D:/xampp/php/xhprof" ;目录要事先建好
在项目里,建立一个公共类文件:
<?php namespace Order\Common\Tool; class XhprofHelper
{
public static function start()
{
if(extension_loaded('xhprof')){
//载入下载的XHPROF包中的2个文件夹
include_once __DIR__ . '/xhprof-0.9.4/xhprof_lib/utils/xhprof_lib.php';
include_once __DIR__ . '/xhprof-0.9.4/xhprof_lib/utils/xhprof_runs.php';
//xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
xhprof_enable( XHPROF_FLAGS_NO_BUILTINS | XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY);
}
} public static function stop()
{
if(extension_loaded('xhprof')){
$ns = 'myXhprof';
//关闭profiler
$xhprofData = xhprof_disable();
//实例化类
$xhprofRuns = new \XHProfRuns_Default();
$runId = $xhprofRuns->save_run($xhprofData, $ns);
//前端展示库的URL
$url = 'http://loc.oms.xhprof:9091/index.php';
$url .= '?run=%s&source=%s';
//变量替换
$url = sprintf($url, $runId, $ns);
//输入URL
echo '<a href="'.$url.'" target="_blank">查看结果</a>';
}
}
}
在项目文件里,调用类方法:
public function getSearchConfig(){
XhprofHelper::start();
$lan = I('get.language', 'zh', 'trim');
$selfPickupType = C('TaiwanYourPickup');
$data['selfPickupType'] = $selfPickupType[$lan];
XhprofHelper::stop();exit;
访问:http://loc.oms.xhprof:9091/callgraph.php?run=5c5430d519c87&source=myXhprof

Xhprof分析php性能的更多相关文章
- 使用xhprof分析php性能
今天偶然发现 xhprof可以远程分析php代码性能,大致步骤如下 1. 进入 xhprof , 点击右上角注册 并 登陆, 网站左侧解释了如何在本地安装测试xhprof, 我用的是右侧的图表模式, ...
- 使用XHProf分析PHP性能瓶颈(二)
上一篇文章里,我们介绍了如何基于xhprof扩展来分析PHP性能,并记录到日志里,最后使用xhprof扩展自带的UI在web里展示出来.本篇文章将讲述2个知识点: 使用xhgui代替xhprof的默认 ...
- 使用XHProf分析PHP性能瓶颈(一)
安装xhprof扩展 wget http://pecl.php.net/get/xhprof-0.9.4.tgz tar zxf xhprof-0.9.4.tgz cd xhprof-0.9.4/ex ...
- 使用 XHProf 分析你的 PHP 程序
个人说明: 注意: php5.5运行 xhprof_enable 会发生段错误Segmentation fault: ,这是一个已知的bug. 下面是报错测试脚本: function loader( ...
- 使用show profiles分析SQL性能
如何查看执行SQL的耗时 使用show profiles分析sql性能. Show profiles是5.0.37之后添加的,要想使用此功能,要确保版本在5.0.37之后. 查看数据库版本 mysql ...
- google perftools分析程序性能
Google perftools 1.功能简介 它的主要功能就是通过采样的方式,给程序中cpu的使用情况进行“画像”,通过它所输出的结果,我们可以对程序中各个函数(得到函数之间的调用关系)耗时情况一目 ...
- 【MS SQL】通过执行计划来分析SQL性能
原文:[MS SQL]通过执行计划来分析SQL性能 如何知道一句SQL语句的执行效率呢,只知道下面3种: 1.通过SQL语句执行时磁盘的活动量(IO)信息来分析:SET STATISTICS IO O ...
- 用 CPI 火焰图分析 Linux 性能问题
https://yq.aliyun.com/articles/465499 用 CPI 火焰图分析 Linux 性能问题 yangoliver 2018-02-11 16:05:53 浏览1076 ...
- 【PHP】善用php-fpm的慢执行日志slow log,分析php性能问题
(转)善用php-fpm的慢执行日志slow log,分析php性能问题 众所周知,mysql有slow query log,根据慢查询日志,我们可以知道那些sql语句有性能问题.作为mysql的好 ...
随机推荐
- Linux系统下如何运行.sh文件
在Linux系统下运行.sh文件有两种方法,比如我在root目录下有个datelog.sh文件 第一种(这种办法需要用chmod使得文件具备执行条件(x): chmod u+x datelog.sh) ...
- VS 2013+ ArcGIS 10.3 AddIn 断点不断异常解决
1. http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#/How_to_debug_add_in ...
- JavaScript 功能类 Url.js
简书原文 这个类的主要目的是为了方便平时编码中的Url类型的数据操作 Github 全局名称 全局名称是由源码的最后一行代码确定的,默认为Url,如存在相同名称的对象会抛出异常: 可以通过 requi ...
- XQuery 术语
XQuery 术语 节点 在 XQuery 中,有七种节点:元素.属性.文本.命名空间.处理指令.注释.以及文档(根)节点.XML 文档是被作为节点树来对待的.树的根被称为文档节点或者根节点. 请看下 ...
- [Swift]LeetCode99. 恢复二叉搜索树 | Recover Binary Search Tree
Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing ...
- [Swift]LeetCode111. 二叉树的最小深度 | Minimum Depth of Binary Tree
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shor ...
- [Java]LeetCode297. 二叉树的序列化与反序列化 | Serialize and Deserialize Binary Tree
Serialization is the process of converting a data structure or object into a sequence of bits so tha ...
- [Swift]LeetCode856. 括号的分数 | Score of Parentheses
Given a balanced parentheses string S, compute the score of the string based on the following rule: ...
- mysql tablespace(独立表空间)超速备份大数据
前序 对于用户自主创建的表,会采用此种模式,每个表由一个独立的表空间进行管理备份(速度相当的猛) 首先介绍一下文件 .ibd就被称之为独立表空间的数据文件 .frm就是元数据文件 就是创建表后生成的 ...
- mysql怎么修改密码
第一种方式: 最简单的方法就是借助第三方工具Navicat for MySQL或Navicat Premium来修改,方法如下: 1.登录mysql到指定库,如:登录到student库. 2.然后点击 ...