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[] = array('Foo'.$i); } $delta = memory_get_usage() - $start; echo 'Memory usage of 1000 service arrays: '.$delta, PHP_EOL; $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;
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.24, 7.3.0 - 7.3.12
Memory usage of 1000 service arrays: 444920 Memory usage of 1000 service objects: 124920
Output for 5.6.0 - 5.6.28
Memory usage of 1000 service arrays: 480712 Memory usage of 1000 service objects: 304432
Output for 5.5.0 - 5.5.38
Memory usage of 1000 service arrays: 480728 Memory usage of 1000 service objects: 304440
Output for 5.4.10 - 5.4.45
Memory usage of 1000 service arrays: 480696 Memory usage of 1000 service objects: 304440
Output for 5.4.0 - 5.4.9
Memory usage of 1000 service arrays: 480712 Memory usage of 1000 service objects: 304464
Output for 5.3.11 - 5.3.29
Memory usage of 1000 service arrays: 480712 Memory usage of 1000 service objects: 528368
Output for 5.3.0 - 5.3.10
Memory usage of 1000 service arrays: 480712 Memory usage of 1000 service objects: 528376
Output for 5.2.10 - 5.2.17
Memory usage of 1000 service arrays: 464704 Memory usage of 1000 service objects: 512528
Output for 5.2.7 - 5.2.9
Memory usage of 1000 service arrays: 465640 Memory usage of 1000 service objects: 383680
Output for 5.2.3 - 5.2.6
Memory usage of 1000 service arrays: 465648 Memory usage of 1000 service objects: 383864
Output for 5.2.2
Memory usage of 1000 service arrays: 465616 Memory usage of 1000 service objects: 383552
Output for 5.2.1
Memory usage of 1000 service arrays: 465016 Memory usage of 1000 service objects: 481320
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/WuJQv 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/WuJQv 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/WuJQv 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/WuJQv on line 5
Process exited with code 255.

preferences:
61.75 ms | 427 KiB | 5 Q