What is the best way to analyze the performance of PHP code, or the code that implements the same functionality? Or would you like to know that the underlying implementation can use VLD to view opcode
Download and install VLD
# wget Http://pecl.php.net/get/vld-0.11.2.tgz
# tar ZXVF vld-0.11.2.tgz
# CD./vld-0.11.2
#/usr/local/php/bin/phpize or Direct phpize
#./configure--with-php-config=/usr/local/php/bin/php-config--ENABLE-VLD
# Make && make install
---------------------------------
Edit php.ini file activation VLD extension:
PHP.ini location
#cd/usr/local/php/lib
Increase
Extension=vld.so
To restart Apache:
#/usr/local/apache2/bin/apachectl Restart
---------------------------------
View Phpinfo () information
650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M00/95/06/wKioL1kRHNiCEveAAACmI2KI8Uo302.jpg-wh_500x0-wm_ 3-wmp_4-s_3597444610.jpg "title=" 1353158957_8977.jpg "alt=" Wkiol1krhniceveaaacmi2ki8uo302.jpg-wh_50 "/>
--------------------------------
At this point, VLD was installed. Write a simple test.php.
<?php
$a = ' 123 ';
echo $a;
?>
# php-dvld.active=1./test.php
If the PHP environment variable is not set
View Results
650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M02/95/06/wKiom1kRHW3Q3Il4AAD5TOehwZI865.jpg-wh_500x0-wm_ 3-wmp_4-s_356743218.jpg "title=" 1353159624_5337.jpg "alt=" Wkiom1krhw3q3il4aad5toehwzi865.jpg-wh_50 "/>
# php-dvld.active=1./test.php
If the PHP environment variable is not set
View Results
As shown above for the VLD output of the PHP code generated by the intermediate code information, described as follows:
Branch analysis from position this information is used when analyzing arrays.
Return found whether it returns, this basically has all.
FileName parsed by file name
function name, for each function VLD generates a separate piece of information, which shows the name of the current function.
Number of OPS generated operands
Compiled VARs the variables during compilation, which are added after PHP5, which is a cache optimization. Such variables are marked with IS_CV in the PHP source code.
List of variables for the intermediate code generated by the OP list
Use the-dvld.active parameter to output the VLD default settings, if you want to see more detailed content. You can use the-dvld.verbosity parameter.
#php-dvld.active=1-dvld.verbosity=3 text.php
-dvld.verbosity=3 is the most detailed information that VLD can display in the current version.
If we just want to see the intermediate code of the output and do not want to execute this PHP code, you can use-dvld.execute=0 to disable the execution of the Code
#php-dvld.active=1-dvld.execute=0 text.php
List of parameters for the VLD extension:
-dvld.active If the VLD hook is activated when PHP is executed, the default is 0, which means disable. Can be enabled using-dvld.active=1.
-dvld.skip_prepend whether to skip the files specified in the php.ini configuration file, the default is 0, which means that the included files are not skipped, showing the intermediate code generated by the code in those contained files. There is a precondition for this parameter to be effective:-dvld.execute=0
-dvld.skip_append whether to skip the files specified in the php.ini configuration file, the default is 0, which means that the included files are not skipped, showing the intermediate code generated by the code in those contained files. There is a precondition for this parameter to be effective:-dvld.execute=0
-dvld.execute whether to execute this PHP script, the default value is 1, indicating execution. You can use-dvld.execute=0 to indicate that only intermediate code is displayed, not the resulting intermediate code.
-dvld.format is displayed in a custom format and defaults to 0, indicating No. You can use-dvld.format=1 to display in a format that you define. The custom format output here is the parameter interval specified in-DVLD.COL_SEP
-dvld.col_sep This function is valid when the-dvld.format parameter is enabled, the default is "\ t".
-dvld.verbosity whether to display more detailed information, the default is 1, its value can be 0,1,2,3 is actually smaller than 0 is also possible, only the effect and 0 like, such as 0.1, but negative, negative and effect and 3 of the effect of the same as 3 of the value is also possible, only the effect and 31.
-DVLD.SAVE_DIR specifies the path to the file output, and the default path is/tmp.
-dvld.save_paths controls whether the output file, default to 0, indicates that the file is not output
-dvld.dump_paths control output content, now only 0 and 12 cases, the default is 1, output content
Compare code differences with VLD
Code text1.php
[PHP] View plain Copy
$var = 111;
$str = "AAA". $var. "BBB";
Code text2.php
[PHP] View plain Copy
$var = 111;
$str = "AAA $var BBB";
650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M02/95/08/wKiom1kRJK_AFYxzAAIeE3-rm3o555.jpg-wh_500x0-wm_ 3-wmp_4-s_227359013.jpg "title=" 1353164246_2967.jpg "alt=" Wkiom1krjk_afyxzaaiee3-rm3o555.jpg-wh_50 "/>
This article is from the "I am the program my biggest" blog, please be sure to keep this source http://skinglzw.blog.51cto.com/10729606/1923487
Install and Use VLD view php's opcode code