3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Service { public $class; public function __construct($class) { $this->class = $class; } } class Container { public $services = array(); } $container = new Container(); $start = memory_get_usage(); for ($i = 0; $i < 1000; $i++) { $container->services[] = new Service('Foo'.$i); } $delta = memory_get_usage() - $start; echo 'Memory usage of 1000 service objects: '.$delta, PHP_EOL; $container = new Container(); $start = memory_get_usage(); for ($i = 0; $i < 1000; $i++) { $container->services[] = array('Foo'.$i); } $delta = memory_get_usage() - $start; echo 'Memory usage of 1000 service arrays: '.$delta;
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.25, 7.2.0 - 7.2.13, 7.3.0 - 7.3.1
Memory usage of 1000 service objects: 124920 Memory usage of 1000 service arrays: 444920
Output for 5.6.0 - 5.6.38
Memory usage of 1000 service objects: 304720 Memory usage of 1000 service arrays: 480400
Output for 5.5.0 - 5.5.38
Memory usage of 1000 service objects: 304728 Memory usage of 1000 service arrays: 480376
Output for 5.4.10 - 5.4.45
Memory usage of 1000 service objects: 304696 Memory usage of 1000 service arrays: 480352
Output for 5.4.0 - 5.4.9
Memory usage of 1000 service objects: 304752 Memory usage of 1000 service arrays: 480384
Output for 5.3.11 - 5.3.29
Memory usage of 1000 service objects: 528680 Memory usage of 1000 service arrays: 480408
Output for 5.3.0 - 5.3.10
Memory usage of 1000 service objects: 528672 Memory usage of 1000 service arrays: 480400
Output for 5.2.10 - 5.2.17
Memory usage of 1000 service objects: 512832 Memory usage of 1000 service arrays: 464416
Output for 5.2.7 - 5.2.9
Memory usage of 1000 service objects: 513928 Memory usage of 1000 service arrays: 359952
Output for 5.2.3 - 5.2.6
Memory usage of 1000 service objects: 513904 Memory usage of 1000 service arrays: 359960
Output for 5.2.2
Memory usage of 1000 service objects: 513864 Memory usage of 1000 service arrays: 359904
Output for 5.2.1
Memory usage of 1000 service objects: 513448 Memory usage of 1000 service arrays: 439080
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0
Fatal error: Call to undefined function memory_get_usage() in /in/cAfcq on line 20
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/cAfcq on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/cAfcq on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/cAfcq on line 5
Process exited with code 255.

preferences:
47.26 ms | 427 KiB | 5 Q