3v4l.org

run code in 300+ PHP versions simultaneously
<?php $times = 10000; $a = []; $m1 = memory_get_usage(true); $s = microtime(true); for ($i = 0; $i < $times; $i++) { $a[] = []; } $e = microtime(true); $m2 = memory_get_usage(true); echo "Empty Array in " . number_format($e - $s, 4) . " using " . ($m2 - $m1) . " bytes of memory\n"; $a = []; $m1 = memory_get_usage(true); $s = microtime(true); for ($i = 0; $i < $times; $i++) { $a[] = new StdClass; } $e = microtime(true); $m2 = memory_get_usage(true); echo "Empty Object in " . number_format($e - $s, 4) . " using " . ($m2 - $m1) . " bytes of memory\n"; $a = []; $m1 = memory_get_usage(true); $s = microtime(true); for ($i = 0; $i < $times; $i++) { $a[] = [ "a" => 1, "b" => 2, "c" => 3, "d" => 4, "e" => 5, "f" => 6, ]; } $e = microtime(true); $m2 = memory_get_usage(true); echo "Non-Empty Array in " . number_format($e - $s, 4) . " using " . ($m2 - $m1) . " bytes of memory\n"; $a = []; $m1 = memory_get_usage(true); $s = microtime(true); for ($i = 0; $i < $times; $i++) { $a[] = (object) [ "a" => 1, "b" => 2, "c" => 3, "d" => 4, "e" => 5, "f" => 6, ]; } $e = microtime(true); $m2 = memory_get_usage(true); echo "Non-Empty Object in " . number_format($e - $s, 4) . " using " . ($m2 - $m1) . " bytes of memory\n";
Output for 7.2.0
Empty Array in 0.0002 using 0 bytes of memory Empty Object in 0.0004 using 0 bytes of memory Non-Empty Array in 0.0002 using 0 bytes of memory Non-Empty Object in 0.0005 using 0 bytes of memory
Output for 7.1.7
Empty Array in 0.0002 using 0 bytes of memory Empty Object in 0.0005 using 0 bytes of memory Non-Empty Array in 0.0002 using 0 bytes of memory Non-Empty Object in 0.0004 using 0 bytes of memory
Output for 7.1.5 - 7.1.6
Empty Array in 0.0004 using 0 bytes of memory Empty Object in 0.0010 using 0 bytes of memory Non-Empty Array in 0.0005 using 0 bytes of memory Non-Empty Object in 0.0009 using 0 bytes of memory
Output for 7.1.0
Empty Array in 0.0003 using 0 bytes of memory Empty Object in 0.0008 using 0 bytes of memory Non-Empty Array in 0.0004 using 0 bytes of memory Non-Empty Object in 0.0007 using 0 bytes of memory
Output for 7.0.20
Empty Array in 0.0003 using 0 bytes of memory Empty Object in 0.0112 using 2097152 bytes of memory Non-Empty Array in 0.0455 using 2097152 bytes of memory Non-Empty Object in 0.0004 using 0 bytes of memory
Output for 7.0.6
Empty Array in 0.0012 using 0 bytes of memory Empty Object in 0.0011 using 2097152 bytes of memory Non-Empty Array in 0.0022 using 2097152 bytes of memory Non-Empty Object in 0.0006 using 0 bytes of memory
Output for 7.0.5
Empty Array in 0.0005 using 0 bytes of memory Empty Object in 0.0006 using 2097152 bytes of memory Non-Empty Array in 0.0012 using 2097152 bytes of memory Non-Empty Object in 0.0003 using 0 bytes of memory
Output for 7.0.4
Empty Array in 0.0005 using 0 bytes of memory Empty Object in 0.0010 using 2097152 bytes of memory Non-Empty Array in 0.0014 using 2097152 bytes of memory Non-Empty Object in 0.0006 using 0 bytes of memory
Output for 7.0.3
Empty Array in 0.0005 using 0 bytes of memory Empty Object in 0.0009 using 2097152 bytes of memory Non-Empty Array in 0.0012 using 2097152 bytes of memory Non-Empty Object in 0.0006 using 0 bytes of memory
Output for 7.0.2
Empty Array in 0.0005 using 0 bytes of memory Empty Object in 0.0009 using 2097152 bytes of memory Non-Empty Array in 0.0012 using 2097152 bytes of memory Non-Empty Object in 0.0005 using 0 bytes of memory
Output for 7.0.1
Empty Array in 0.0006 using 0 bytes of memory Empty Object in 0.0009 using 2097152 bytes of memory Non-Empty Array in 0.0011 using 2097152 bytes of memory Non-Empty Object in 0.0007 using 0 bytes of memory
Output for 7.0.0
Empty Array in 0.0005 using 0 bytes of memory Empty Object in 0.0010 using 2097152 bytes of memory Non-Empty Array in 0.0013 using 2097152 bytes of memory Non-Empty Object in 0.0006 using 0 bytes of memory
Output for 5.6.28
Empty Array in 0.0018 using 2359296 bytes of memory Empty Object in 0.0018 using 2883584 bytes of memory Non-Empty Array in 0.0070 using 10485760 bytes of memory Non-Empty Object in 0.0056 using 10747904 bytes of memory
Output for 5.6.21
Empty Array in 0.0031 using 2359296 bytes of memory Empty Object in 0.0030 using 2883584 bytes of memory Non-Empty Array in 0.0106 using 10485760 bytes of memory Non-Empty Object in 0.0075 using 10747904 bytes of memory
Output for 5.6.20
Empty Array in 0.0026 using 2359296 bytes of memory Empty Object in 0.0025 using 2883584 bytes of memory Non-Empty Array in 0.0093 using 10485760 bytes of memory Non-Empty Object in 0.0067 using 10747904 bytes of memory
Output for 5.6.19
Empty Array in 0.0026 using 2359296 bytes of memory Empty Object in 0.0024 using 2883584 bytes of memory Non-Empty Array in 0.0092 using 10485760 bytes of memory Non-Empty Object in 0.0066 using 10747904 bytes of memory
Output for 5.6.18
Empty Array in 0.0019 using 2359296 bytes of memory Empty Object in 0.0019 using 2883584 bytes of memory Non-Empty Array in 0.0068 using 10485760 bytes of memory Non-Empty Object in 0.0051 using 10747904 bytes of memory
Output for 5.6.17
Empty Array in 0.0024 using 2359296 bytes of memory Empty Object in 0.0024 using 2883584 bytes of memory Non-Empty Array in 0.0088 using 10485760 bytes of memory Non-Empty Object in 0.0064 using 10747904 bytes of memory
Output for 5.6.16
Empty Array in 0.0027 using 2359296 bytes of memory Empty Object in 0.0027 using 2883584 bytes of memory Non-Empty Array in 0.0098 using 10485760 bytes of memory Non-Empty Object in 0.0071 using 10747904 bytes of memory
Output for 5.6.15
Empty Array in 0.0019 using 2359296 bytes of memory Empty Object in 0.0019 using 2883584 bytes of memory Non-Empty Array in 0.0069 using 10485760 bytes of memory Non-Empty Object in 0.0051 using 10747904 bytes of memory
Output for 5.6.14
Empty Array in 0.0020 using 2359296 bytes of memory Empty Object in 0.0019 using 2883584 bytes of memory Non-Empty Array in 0.0071 using 10485760 bytes of memory Non-Empty Object in 0.0052 using 10747904 bytes of memory
Output for 5.6.13
Empty Array in 0.0026 using 2359296 bytes of memory Empty Object in 0.0026 using 2883584 bytes of memory Non-Empty Array in 0.0094 using 10485760 bytes of memory Non-Empty Object in 0.0067 using 10747904 bytes of memory
Output for 5.6.12
Empty Array in 0.0019 using 2359296 bytes of memory Empty Object in 0.0019 using 2883584 bytes of memory Non-Empty Array in 0.0071 using 10485760 bytes of memory Non-Empty Object in 0.0051 using 10747904 bytes of memory
Output for 5.6.11
Empty Array in 0.0029 using 2359296 bytes of memory Empty Object in 0.0027 using 2883584 bytes of memory Non-Empty Array in 0.0100 using 10485760 bytes of memory Non-Empty Object in 0.0070 using 10747904 bytes of memory
Output for 5.6.10
Empty Array in 0.0029 using 2359296 bytes of memory Empty Object in 0.0028 using 2883584 bytes of memory Non-Empty Array in 0.0099 using 10485760 bytes of memory Non-Empty Object in 0.0070 using 10747904 bytes of memory
Output for 5.6.9
Empty Array in 0.0029 using 2359296 bytes of memory Empty Object in 0.0029 using 2883584 bytes of memory Non-Empty Array in 0.0100 using 10485760 bytes of memory Non-Empty Object in 0.0071 using 10747904 bytes of memory
Output for 5.6.8
Empty Array in 0.0034 using 2359296 bytes of memory Empty Object in 0.0031 using 2883584 bytes of memory Non-Empty Array in 0.0109 using 10485760 bytes of memory Non-Empty Object in 0.0080 using 10747904 bytes of memory
Output for 5.5.35
Empty Array in 0.0019 using 2359296 bytes of memory Empty Object in 0.0023 using 2883584 bytes of memory Non-Empty Array in 0.0067 using 10485760 bytes of memory Non-Empty Object in 0.0051 using 10747904 bytes of memory
Output for 5.5.34
Empty Array in 0.0027 using 2359296 bytes of memory Empty Object in 0.0038 using 2883584 bytes of memory Non-Empty Array in 0.0108 using 10485760 bytes of memory Non-Empty Object in 0.0096 using 10747904 bytes of memory
Output for 5.5.33
Empty Array in 0.0021 using 2359296 bytes of memory Empty Object in 0.0025 using 2883584 bytes of memory Non-Empty Array in 0.0077 using 10485760 bytes of memory Non-Empty Object in 0.0060 using 10747904 bytes of memory
Output for 5.5.32
Empty Array in 0.0021 using 2359296 bytes of memory Empty Object in 0.0026 using 2883584 bytes of memory Non-Empty Array in 0.0077 using 10485760 bytes of memory Non-Empty Object in 0.0058 using 10747904 bytes of memory
Output for 5.5.31
Empty Array in 0.0027 using 2359296 bytes of memory Empty Object in 0.0034 using 2883584 bytes of memory Non-Empty Array in 0.0094 using 10485760 bytes of memory Non-Empty Object in 0.0068 using 10747904 bytes of memory
Output for 5.5.30
Empty Array in 0.0019 using 2359296 bytes of memory Empty Object in 0.0024 using 2883584 bytes of memory Non-Empty Array in 0.0070 using 10485760 bytes of memory Non-Empty Object in 0.0053 using 10747904 bytes of memory
Output for 5.5.29
Empty Array in 0.0018 using 2359296 bytes of memory Empty Object in 0.0023 using 2883584 bytes of memory Non-Empty Array in 0.0067 using 10485760 bytes of memory Non-Empty Object in 0.0051 using 10747904 bytes of memory
Output for 5.5.28
Empty Array in 0.0029 using 2359296 bytes of memory Empty Object in 0.0035 using 2883584 bytes of memory Non-Empty Array in 0.0104 using 10485760 bytes of memory Non-Empty Object in 0.0075 using 10747904 bytes of memory
Output for 5.5.27
Empty Array in 0.0022 using 2359296 bytes of memory Empty Object in 0.0028 using 2883584 bytes of memory Non-Empty Array in 0.0080 using 10485760 bytes of memory Non-Empty Object in 0.0066 using 10747904 bytes of memory
Output for 5.5.26
Empty Array in 0.0018 using 2359296 bytes of memory Empty Object in 0.0023 using 2883584 bytes of memory Non-Empty Array in 0.0074 using 10485760 bytes of memory Non-Empty Object in 0.0054 using 10747904 bytes of memory
Output for 5.5.25
Empty Array in 0.0028 using 2359296 bytes of memory Empty Object in 0.0033 using 2883584 bytes of memory Non-Empty Array in 0.0095 using 10485760 bytes of memory Non-Empty Object in 0.0069 using 10747904 bytes of memory
Output for 5.5.24
Empty Array in 0.0022 using 2359296 bytes of memory Empty Object in 0.0026 using 2883584 bytes of memory Non-Empty Array in 0.0076 using 10485760 bytes of memory Non-Empty Object in 0.0055 using 10747904 bytes of memory
Output for 5.4.45
Empty Array in 0.0029 using 2359296 bytes of memory Empty Object in 0.0034 using 2883584 bytes of memory Non-Empty Array in 0.0125 using 10485760 bytes of memory Non-Empty Object in 0.0089 using 10747904 bytes of memory
Output for 5.4.44
Empty Array in 0.0035 using 2359296 bytes of memory Empty Object in 0.0038 using 2883584 bytes of memory Non-Empty Array in 0.0122 using 10485760 bytes of memory Non-Empty Object in 0.0092 using 10747904 bytes of memory
Output for 5.4.43
Empty Array in 0.0033 using 2359296 bytes of memory Empty Object in 0.0033 using 2883584 bytes of memory Non-Empty Array in 0.0116 using 10485760 bytes of memory Non-Empty Object in 0.0084 using 10747904 bytes of memory
Output for 5.4.42
Empty Array in 0.0031 using 2359296 bytes of memory Empty Object in 0.0035 using 2883584 bytes of memory Non-Empty Array in 0.0120 using 10485760 bytes of memory Non-Empty Object in 0.0086 using 10747904 bytes of memory
Output for 5.4.41
Empty Array in 0.0031 using 2359296 bytes of memory Empty Object in 0.0034 using 2883584 bytes of memory Non-Empty Array in 0.0126 using 10485760 bytes of memory Non-Empty Object in 0.0093 using 10747904 bytes of memory
Output for 5.4.40
Empty Array in 0.0031 using 2359296 bytes of memory Empty Object in 0.0040 using 2883584 bytes of memory Non-Empty Array in 0.0122 using 10485760 bytes of memory Non-Empty Object in 0.0090 using 10747904 bytes of memory
Output for 5.4.39
Empty Array in 0.0031 using 2359296 bytes of memory Empty Object in 0.0034 using 2883584 bytes of memory Non-Empty Array in 0.0115 using 10485760 bytes of memory Non-Empty Object in 0.0077 using 10747904 bytes of memory
Output for 5.4.38
Empty Array in 0.0030 using 2359296 bytes of memory Empty Object in 0.0040 using 2883584 bytes of memory Non-Empty Array in 0.0115 using 10485760 bytes of memory Non-Empty Object in 0.0082 using 10747904 bytes of memory
Output for 5.4.37
Empty Array in 0.0031 using 2359296 bytes of memory Empty Object in 0.0043 using 2883584 bytes of memory Non-Empty Array in 0.0131 using 10485760 bytes of memory Non-Empty Object in 0.0102 using 10747904 bytes of memory
Output for 5.4.36
Empty Array in 0.0032 using 2359296 bytes of memory Empty Object in 0.0047 using 2883584 bytes of memory Non-Empty Array in 0.0124 using 10485760 bytes of memory Non-Empty Object in 0.0092 using 10747904 bytes of memory
Output for 5.4.35
Empty Array in 0.0033 using 2359296 bytes of memory Empty Object in 0.0032 using 2883584 bytes of memory Non-Empty Array in 0.0117 using 10485760 bytes of memory Non-Empty Object in 0.0079 using 10747904 bytes of memory
Output for 5.4.34
Empty Array in 0.0032 using 2359296 bytes of memory Empty Object in 0.0043 using 2883584 bytes of memory Non-Empty Array in 0.0132 using 10485760 bytes of memory Non-Empty Object in 0.0099 using 10747904 bytes of memory
Output for 5.4.32
Empty Array in 0.0029 using 2359296 bytes of memory Empty Object in 0.0040 using 2883584 bytes of memory Non-Empty Array in 0.0119 using 10485760 bytes of memory Non-Empty Object in 0.0082 using 10747904 bytes of memory
Output for 5.4.31
Empty Array in 0.0031 using 2359296 bytes of memory Empty Object in 0.0045 using 2883584 bytes of memory Non-Empty Array in 0.0119 using 10485760 bytes of memory Non-Empty Object in 0.0082 using 10747904 bytes of memory
Output for 5.4.30
Empty Array in 0.0029 using 2359296 bytes of memory Empty Object in 0.0033 using 2883584 bytes of memory Non-Empty Array in 0.0125 using 10485760 bytes of memory Non-Empty Object in 0.0075 using 10747904 bytes of memory
Output for 5.4.29
Empty Array in 0.0032 using 2359296 bytes of memory Empty Object in 0.0036 using 2883584 bytes of memory Non-Empty Array in 0.0123 using 10485760 bytes of memory Non-Empty Object in 0.0079 using 10747904 bytes of memory
Output for 5.4.28
Empty Array in 0.0029 using 2359296 bytes of memory Empty Object in 0.0032 using 2883584 bytes of memory Non-Empty Array in 0.0114 using 10485760 bytes of memory Non-Empty Object in 0.0096 using 10747904 bytes of memory
Output for 5.4.27
Empty Array in 0.0030 using 2359296 bytes of memory Empty Object in 0.0036 using 2883584 bytes of memory Non-Empty Array in 0.0127 using 10485760 bytes of memory Non-Empty Object in 0.0091 using 10747904 bytes of memory
Output for 5.4.26
Empty Array in 0.0030 using 2359296 bytes of memory Empty Object in 0.0032 using 2883584 bytes of memory Non-Empty Array in 0.0130 using 10485760 bytes of memory Non-Empty Object in 0.0078 using 10747904 bytes of memory
Output for 5.4.25
Empty Array in 0.0032 using 2359296 bytes of memory Empty Object in 0.0035 using 2883584 bytes of memory Non-Empty Array in 0.0130 using 10485760 bytes of memory Non-Empty Object in 0.0096 using 10747904 bytes of memory
Output for 5.4.24
Empty Array in 0.0047 using 2359296 bytes of memory Empty Object in 0.0058 using 2883584 bytes of memory Non-Empty Array in 0.0160 using 10485760 bytes of memory Non-Empty Object in 0.0138 using 10747904 bytes of memory
Output for 5.4.23
Empty Array in 0.0032 using 2359296 bytes of memory Empty Object in 0.0034 using 2883584 bytes of memory Non-Empty Array in 0.0128 using 10485760 bytes of memory Non-Empty Object in 0.0090 using 10747904 bytes of memory
Output for 5.4.22
Empty Array in 0.0046 using 2359296 bytes of memory Empty Object in 0.0068 using 2883584 bytes of memory Non-Empty Array in 0.0188 using 10485760 bytes of memory Non-Empty Object in 0.0153 using 10747904 bytes of memory
Output for 5.4.21
Empty Array in 0.0034 using 2359296 bytes of memory Empty Object in 0.0035 using 2883584 bytes of memory Non-Empty Array in 0.0129 using 10485760 bytes of memory Non-Empty Object in 0.0089 using 10747904 bytes of memory
Output for 5.4.20
Empty Array in 0.0032 using 2359296 bytes of memory Empty Object in 0.0047 using 2883584 bytes of memory Non-Empty Array in 0.0153 using 10485760 bytes of memory Non-Empty Object in 0.0083 using 10747904 bytes of memory
Output for 5.4.19
Empty Array in 0.0032 using 2359296 bytes of memory Empty Object in 0.0051 using 2883584 bytes of memory Non-Empty Array in 0.0130 using 10485760 bytes of memory Non-Empty Object in 0.0096 using 10747904 bytes of memory
Output for 5.4.18
Empty Array in 0.0034 using 2359296 bytes of memory Empty Object in 0.0045 using 2883584 bytes of memory Non-Empty Array in 0.0125 using 10485760 bytes of memory Non-Empty Object in 0.0090 using 10747904 bytes of memory
Output for 5.4.17
Empty Array in 0.0030 using 2359296 bytes of memory Empty Object in 0.0050 using 2883584 bytes of memory Non-Empty Array in 0.0133 using 10485760 bytes of memory Non-Empty Object in 0.0099 using 10747904 bytes of memory
Output for 5.4.16
Empty Array in 0.0030 using 2359296 bytes of memory Empty Object in 0.0038 using 2883584 bytes of memory Non-Empty Array in 0.0124 using 10485760 bytes of memory Non-Empty Object in 0.0102 using 10747904 bytes of memory
Output for 5.4.15
Empty Array in 0.0033 using 2359296 bytes of memory Empty Object in 0.0038 using 2883584 bytes of memory Non-Empty Array in 0.0132 using 10485760 bytes of memory Non-Empty Object in 0.0089 using 10747904 bytes of memory
Output for 5.4.14
Empty Array in 0.0060 using 2359296 bytes of memory Empty Object in 0.0057 using 2883584 bytes of memory Non-Empty Array in 0.0139 using 10485760 bytes of memory Non-Empty Object in 0.0148 using 10747904 bytes of memory
Output for 5.4.13
Empty Array in 0.0033 using 2359296 bytes of memory Empty Object in 0.0034 using 2883584 bytes of memory Non-Empty Array in 0.0125 using 10485760 bytes of memory Non-Empty Object in 0.0095 using 10747904 bytes of memory
Output for 5.4.12
Empty Array in 0.0032 using 2359296 bytes of memory Empty Object in 0.0032 using 2883584 bytes of memory Non-Empty Array in 0.0129 using 10485760 bytes of memory Non-Empty Object in 0.0086 using 10747904 bytes of memory
Output for 5.4.11
Empty Array in 0.0033 using 2359296 bytes of memory Empty Object in 0.0040 using 2883584 bytes of memory Non-Empty Array in 0.0140 using 10485760 bytes of memory Non-Empty Object in 0.0101 using 10747904 bytes of memory
Output for 5.4.10
Empty Array in 0.0030 using 2359296 bytes of memory Empty Object in 0.0032 using 2883584 bytes of memory Non-Empty Array in 0.0128 using 10485760 bytes of memory Non-Empty Object in 0.0079 using 10747904 bytes of memory
Output for 5.4.9
Empty Array in 0.0047 using 2359296 bytes of memory Empty Object in 0.0055 using 2883584 bytes of memory Non-Empty Array in 0.0137 using 10485760 bytes of memory Non-Empty Object in 0.0093 using 10747904 bytes of memory
Output for 5.4.8
Empty Array in 0.0032 using 2359296 bytes of memory Empty Object in 0.0033 using 2883584 bytes of memory Non-Empty Array in 0.0160 using 10485760 bytes of memory Non-Empty Object in 0.0140 using 10747904 bytes of memory
Output for 5.4.7
Empty Array in 0.0044 using 2359296 bytes of memory Empty Object in 0.0056 using 2883584 bytes of memory Non-Empty Array in 0.0147 using 10485760 bytes of memory Non-Empty Object in 0.0065 using 10747904 bytes of memory
Output for 5.4.6
Empty Array in 0.0028 using 2359296 bytes of memory Empty Object in 0.0034 using 2883584 bytes of memory Non-Empty Array in 0.0098 using 10485760 bytes of memory Non-Empty Object in 0.0070 using 10747904 bytes of memory
Output for 5.4.5
Empty Array in 0.0020 using 2359296 bytes of memory Empty Object in 0.0024 using 2883584 bytes of memory Non-Empty Array in 0.0072 using 10485760 bytes of memory Non-Empty Object in 0.0052 using 10747904 bytes of memory
Output for 5.4.2, 5.4.4
Empty Array in 0.0023 using 2359296 bytes of memory Empty Object in 0.0028 using 2883584 bytes of memory Non-Empty Array in 0.0083 using 10485760 bytes of memory Non-Empty Object in 0.0058 using 10747904 bytes of memory
Output for 5.4.3
Empty Array in 0.0028 using 2359296 bytes of memory Empty Object in 0.0034 using 2883584 bytes of memory Non-Empty Array in 0.0088 using 10485760 bytes of memory Non-Empty Object in 0.0065 using 10747904 bytes of memory

preferences:
64.27 ms | 401 KiB | 88 Q