1) dd if=/dev/zero of=/swapfile bs=1M count=1024
2) mkswap /swapfile
3) swapon /swapfile
4) 添加这行: /swapfile swap swap defaults 0 0 到 /etc/fstab
月份:2014年2月
Git修改已经commit的注释信息
git commit --amend
XHProf安装和使用
wget http://pecl.php.net/get/xhprof-0.9.4.tgz
tar zxf xhprof-0.9.4.tgz
cd xhprof-0.9.4/extension/
sudo phpize
./configure
sudo make
sudo make install
在php.ini里加入
[xhprof]
extension=xhprof.so;
; directory used by default implementation of the iXHProfRuns
; interface (namely, the XHProfRuns_Default class) for storing
; XHProf runs.
;
;xhprof.output_dir=<directory_for_storing_xhprof_runs>
xhprof.output_dir=/tmp/xhprof
安装Graphviz
创建/tmp/xhprof目录并分配写入权限
将代码加入到要测试的php当中
<?pho
// cpu:XHPROF_FLAGS_CPU 内存:XHPROF_FLAGS_MEMORY
// 如果两个一起:XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
// 要测试的php代码
//…
$data = xhprof_disable(); //返回运行数据
// xhprof_lib在下载的包里存在这个目录,记得将目录包含到运行的php代码中
include_once “xhprof_lib/utils/xhprof_lib.php”;
include_once “xhprof_lib/utils/xhprof_runs.php”;
$objXhprofRun = new XHProfRuns_Default();
// 第一个参数j是xhprof_disable()函数返回的运行信息
// 第二个参数是自定义的命名空间字符串(任意字符串),
// 返回运行ID,用这个ID查看相关的运行结果
$run_id = $objXhprofRun->save_run($data, “xhprof”);
var_dump($run_id);
查看运行结果
将xhprof_lib&&xhprof_html相关目录copy到可以访问到的地址
访问 xxx/xhprof_html/index.php?run=$run_id&source=xhprof 就可经看到你的php代码运行的相关情况
下面是一些参数说明
Inclusive Time 包括子函数所有执行时间。
Exclusive Time/Self Time 函数执行本身花费的时间,不包括子树执行时间。
Wall Time 花去了的时间或挂钟时间。
CPU Time 用户耗的时间+内核耗的时间
Inclusive CPU 包括子函数一起所占用的CPU
Exclusive CPU 函数自身所占用的CPU
Fedora 20 编译 PHP 5.5
git 官方地址: git clone https://git.php.net/repository/php-src.git 或 github 官方镜像: git clone git://github.com/php/php-src.git cd php-src 签出5.5分支: git checkout PHP-5.5 编译: ./buildconf ./configure 若出现: configure: WARNING: bison versions supported for regeneration of the Zend/PHP parsers: 2.4 2.4.1 2.4.2 2.4.3 2.5 2.5.1 2.6 2.6.1 2.6.2 2.6.3 2.6.4 2.6.5 2.7 (found: none). 解决方法: sudo yum install bison ./configure --disable-all make ./sapi/cli/php -v 若编译成功,此时可以看到 PHP 版本信息
使用 Eclipse 开发 PHP: 将 php-src 导入: import -> Existing Code as makefile Project 点击 Run Configurations -> C/c++ Application -> New Launch configuration 在 Main -> C/C++ Application 中输入: ./sapi/cli/php 在 Arguments -> Program arguments 中输入: -i 在菜单栏点击:Run php-src Default 可以看到 Console 中输出的信息 如果出现警告: Unresolved inclusion:解决方法: 项目属性 -> C/C++ General ->Paths and Symbols -> Includes -> GNU C -> Add,输入: /usr/include/ 等待 C/C++ Indexer 执行完毕,红色的警告将消失