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: |
Copy code |
$ 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: |
Copy code |
$ 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 ~~