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[] = array('Foo'.$i); } $delta = memory_get_usage() - $start; echo 'Memory usage of 1000 service arrays: '.$delta; $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;
Output for 7.0.0 - 7.1.0
Memory usage of 1000 service arrays: 444920Memory usage of 1000 service objects: 124920
Output for hhvm-3.10.0 - 3.12.0
Memory usage of 1000 service arrays: 0Memory usage of 1000 service objects: 0
Output for 5.6.0 - 5.6.28
Memory usage of 1000 service arrays: 480664Memory usage of 1000 service objects: 304432
Output for 5.5.0 - 5.5.38
Memory usage of 1000 service arrays: 480680Memory usage of 1000 service objects: 304464
Output for 5.4.10 - 5.4.45
Memory usage of 1000 service arrays: 480664Memory usage of 1000 service objects: 304440
Output for 5.4.0 - 5.4.9
Memory usage of 1000 service arrays: 480696Memory usage of 1000 service objects: 304440
Output for 5.3.11 - 5.3.29
Memory usage of 1000 service arrays: 480712Memory usage of 1000 service objects: 528368
Output for 5.3.0 - 5.3.10
Memory usage of 1000 service arrays: 480712Memory usage of 1000 service objects: 528376
Output for 5.2.10 - 5.2.17
Memory usage of 1000 service arrays: 464704Memory usage of 1000 service objects: 512528
Output for 5.2.7 - 5.2.9
Memory usage of 1000 service arrays: 465672Memory usage of 1000 service objects: 383680
Output for 5.2.3 - 5.2.6
Memory usage of 1000 service arrays: 465680Memory usage of 1000 service objects: 383864
Output for 5.2.2
Memory usage of 1000 service arrays: 465648Memory usage of 1000 service objects: 383656
Output for 5.2.1
Memory usage of 1000 service arrays: 465048Memory usage of 1000 service objects: 481328
Output for 5.0.0 - 5.2.0
Fatal error: Call to undefined function memory_get_usage() in /in/Cc9VI 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/Cc9VI 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/Cc9VI 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/Cc9VI on line 5
Process exited with code 255.