标签:
#官网下载 http: //pecl .php.net /package/xhprof tar zxf xhprof-0.9.2.tgz cd xhprof-0.9.2 /extension/ sudo phpize . /configure --with-php-config= /usr/local/php/bin/php-config 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 |
php中的代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY); /** monitor begin */ include ‘common.php‘ ; $host = ‘127.0.0.1‘ ; $port = 11216; $objMc = new Memcache(); $objMc ->addServer( $host , $port ,true,1,1,15,true ); $key = ‘test‘ ; $value = file_get_contents ( ‘b.js‘ ); $str = md5( $value ); dump( $str ); $objMc ->set( $key , $value ); md5( base64_encode (pack( ‘N6‘ , mt_rand(), mt_rand(), mt_rand(), mt_rand(), mt_rand(), uniqid()))); $rs = $objMc ->get( $key ); dump( md5( $rs ) ); dump( $rs ) ; $data = xhprof_disable(); include_once "xhprof_lib/utils/xhprof_lib.php" ; include_once "xhprof_lib/utils/xhprof_runs.php" ; $objXhprofRun = new XHProfRuns_Default(); $run_id = $objXhprofRun ->save_run( $data , ‘memcache‘ ); /** monitor end */ dump( $run_id ); exit ; |
标签:
原文地址:http://www.cnblogs.com/allenhaozi/p/4508407.html