3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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.1.0
Memory usage of 1000 service objects: 124920 Memory usage of 1000 service arrays: 444920
Output for hhvm-3.10.0 - 3.12.0
Memory usage of 1000 service objects: 0 Memory usage of 1000 service arrays: 0
Output for 5.6.7 - 5.6.28
Memory usage of 1000 service objects: 304712 Memory usage of 1000 service arrays: 480368
Output for 5.5.24 - 5.5.35
Memory usage of 1000 service objects: 304720 Memory usage of 1000 service arrays: 480360
Output for 5.4.10 - 5.4.45
Memory usage of 1000 service objects: 304720 Memory usage of 1000 service arrays: 480352
Output for 5.4.0 - 5.4.9
Memory usage of 1000 service objects: 304736 Memory usage of 1000 service arrays: 480360
Output for 5.3.11 - 5.3.29
Memory usage of 1000 service objects: 528656 Memory usage of 1000 service arrays: 480400
Output for 5.3.0 - 5.3.10
Memory usage of 1000 service objects: 528704 Memory usage of 1000 service arrays: 480400
Output for 5.2.10 - 5.2.17
Memory usage of 1000 service objects: 512816 Memory usage of 1000 service arrays: 464448
Output for 5.2.7 - 5.2.9
Memory usage of 1000 service objects: 513912 Memory usage of 1000 service arrays: 359968
Output for 5.2.3 - 5.2.6
Memory usage of 1000 service objects: 513936 Memory usage of 1000 service arrays: 359976
Output for 5.2.2
Memory usage of 1000 service objects: 513816 Memory usage of 1000 service arrays: 359888
Output for 5.2.1
Memory usage of 1000 service objects: 513344 Memory usage of 1000 service arrays: 439000
Output for 5.0.0 - 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.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.