php opcache安装配置和性能测试

Posted on 2014-07-24 12:36:54 | 1 comments | 3584℃ | PHP

关于opcache

php5.5.14,lnmp安装opcache。虽然php5.5默认集成了opcache,但编译时仍需使用 --enable-opcache 选项来开启OPcache。

行动

本次使用upgrade_php.sh进行php更新。

  1. 由于之前已经将lnmp的php版本升级到了5.5.14,故先将版本检查注释掉:
    
    #       if [ "$php_version" == "$old_php_version" ]; then
    #               echo "Error: The upgrade PHP Version is the same as the old Version!!"
    #               exit 1
    #       fi
    ``...

编译安装swoole

Posted on 2014-07-21 11:10:24 | 0 comments | 2856℃ | PHP

下载

https://github.com/swoole/swoole-src/releases下载最新release版本

解压后:

安装

和一般的php扩展安装无异

phpize

执行后,目录下会生成一些configure文件。

./configure --with-php-config=/usr/local/php/bin/php-config

默认php安装路径情况下with-php-config路径为上所示

make && sudo make install

提示:


Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non...

php抓取SyntaxHighlighter的cdn的min文件

Posted on 2014-07-19 11:36:51 | 0 comments | 3033℃ | PHP

关于SyntaxHighlighter

什么是SyntaxHighlighter?

SyntaxHighlighter是一个代码高亮的js插件,见本文下方代码。 官方下载地址:

http://alexgorbatchev.com/SyntaxHighlighter/download/

但他没有提供压缩版的js和css,于是想到了自己手动压缩,但文件有几十个,人懒怎么办?只能另想办法。

如何操作?

http://cdnjs.com/libraries/SyntaxHighlighter

这里有SyntaxHighlighter的cdn提供,并且有min版的。好了,把里面的东西复制下来粘贴到$str变量里面:


header("Content-type: text/html;...

CURL, rolling CURL,SOAP的性能比较

Posted on 2014-07-19 09:50:01 | 0 comments | 3282℃ | PHP

前言

这个是很久以前做的一个测试,当时是为了确定新项目使用什么来进行通信。之前一直用soap,但感觉性能方面不是很好。现在贴出来,顺便分享一下curl和rolling curl的代码。

上代码

CURL


function makeRequest($url, $params, $method = 'post', $protocol = 'http'){
    $query_string = '';
    if(is_array($params)){
        $query_string = http_build_query($params);
    }elseif(is_string($params)){
        $query_string = $params;...

micromvc实现自动读写分离

Posted on 2014-07-17 12:27:30 | 6 comments | 3534℃ | PHP

前言

看到php框架性能比较发现有个php框架micromvc,性能测试仅次于yaf和phancon,于是好奇这是个什么样的框架

git下来后看了下代码,感觉不太给力,但有些地方还是可以借鉴的。看了一下他的orm,很简单,但不支持读写分离,于是自己动手改了一下:

上代码

配置

Config/Config.php


$config['database'] = array(
    'dns' => "mysql:host=127.0.0.1;port=3306;dbname=micromvc,mysql:host=127.0.0.1;port=3306;dbname=micromvcslave",
    'username' => 'root',
    'password' => '',...
UP