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的好 ...
随机推荐
- win10 vscode使用 智能提示
1.没有第三方库的智能提示 参考:https://code.visualstudio.com/docs/python/editing 1.点开Settings 2.搜索加添加 3.添加后的内容 然后就 ...
- c++实验二
1.函数重载编程练习编写重载函数add(),实现对int型,double型,Complex型数据的加法 #include<iostream> using namespace std; st ...
- Lua学习----零碎知识点
Jit(just in time) 动态即时编译,边运行时边编译---->lua (主要是面向进程) Aot(ahead of time) 静态提前编译,运行前编译---->C#(主要是面 ...
- ThinkPHP5 打开多语言支持
1.在thinkphp\start.php 页面中添加多语言的切换函数的参数格式,本贴目前只支持两种语言,并注意必须全部小写!全部小写!!全部小写!!!,注意这一步很关键 Lang::setAllow ...
- 将选中的物体写入XML文件
using System.Collections;using System.Collections.Generic;using System.Xml.Linq;using UnityEditor;us ...
- 吴恩达机器学习笔记52-异常检测的问题动机与高斯分布(Problem Motivation of Anomaly Detection& Gaussian Distribution)
一.问题动机 异常检测(Anomaly detection)问题是机器学习算法的一个常见应用.这种算法的一个有趣之处在于:它虽然主要用于非监督学习问题,但从某些角度看,它又类似于一些监督学习问题. 给 ...
- [Swift]LeetCode58. 最后一个单词的长度 | Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the l ...
- [Swift]LeetCode543. 二叉树的直径 | Diameter of Binary Tree
Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a b ...
- [Swift]LeetCode764. 最大加号标志 | Largest Plus Sign
In a 2D grid from (0, 0) to (N-1, N-1), every cell contains a 1, except those cells in the given lis ...
- [Swift]LeetCode898. 子数组按位或操作 | Bitwise ORs of Subarrays
We have an array A of non-negative integers. For every (contiguous) subarray B = [A[i], A[i+1], ..., ...