Use the built-in Math function of PHP with caution. The article details some of the usage procedures of PHP's built-in Math functions. I hope some methods will be helpful to you. As shown in the following figure... I do not know how to perform large-scale operations... The article details some of the usage procedures of PHP's built-in Math functions. I hope some methods will be helpful to you.
As shown in the following figure... I do not know how to perform large-scale operations... The Math function operation in PHP is so slow... You are still in trouble. you need to write a few more words in hand to calculate the number of birds ~~~
Xiao 'er! On the code ....
The code is as follows: |
|
$ Start = microtime (TRUE ); For ($ I = 0; I I <200000; $ I ++ ){ $ S = 0; for ($ j = 0; $ j <3; $ j ++ ){ $ S + = ($ j + $ I + 1) * ($ j + $ I + 1 );} } Echo microtime (TRUE)-$ start; # output: 0.33167719841003 |
Then compare the code and results of using the Math function
The code is as follows: |
|
$ Start = microtime (TRUE ); For ($ I = 0; I I <200000; $ I ++ ){ $ S = 0; for ($ j = 0; $ j <3; $ j ++ ){ $ S + = pow ($ j + $ I + 1, 2 );} } Echo microtime (TRUE)-$ start; # output: 0.87528896331787 |
The efficiency is improved by 100%... I used to think it was PHP's built-in Math that was fast, but I don't know if I did .. Such as taking absolute abs, maximum max, and minimum min values is less efficient than native if to Judge faster ~~
In general, php operations are really slow ~~ It is really not suitable for large-scale algorithm operations ~~
Bytes. As shown in the following figure... I don't know how to perform large-scale operations on wood ......