Script Speed ​​and Memory Usage

I am working on creating a script image in PHP and got it working in two ways. One way is slow, but uses a limited amount of memory, the second is much faster, but uses 6x memory. There is no leak in the script (as far as I can tell).

In a limited test, here's how they ran:

--------------------------------------------
METHOD | TOTAL TIME | PEAK MEMORY | IMAGES
--------------------------------------------
One | 65.626 | 540,036 | 200
Two | 20.207 | 3,269,600 | 200
--------------------------------------------

And here is the average of the previous numbers (if you do not want to do your own math):

--------------------------------------------
METHOD | TOTAL TIME | PEAK MEMORY | IMAGES
--------------------------------------------
One | 0.328 | 540,036 | 1
Two | 0.101 | 3,269,600 | 1
--------------------------------------------

Which method to use and why?

, , 10-20 script .

, , , 1/3 .

. , . , :

--------------------------------------------
METHOD  | TOTAL TIME | PEAK MEMORY |  IMAGES
--------------------------------------------
One     |     51.901 |     798,900 |     200
Two     |     12.039 |   3,269,600 |     200
Three   |     13.667 |   1,815,624 |     200
--------------------------------------------

!

+3
3

. , . , , . ( ) ram , .

, ? , - . - , . xdebug, .

+2

, , . , , " " - "" 3 . , swapping, ...

+2

, , - memcached, . .

0

Source: https://habr.com/ru/post/1737783/


All Articles