3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Object hashing tests. */ $sos = new SplObjectStorage(); $docs = array(); $iterations = (int) 10; //100000; for ($i = 0; $i < $iterations; ++$i) { $doc = new DOMDocument(); //$doc = new stdClass(); $docs[] = $doc; } $start = $finis = 0; $mem_empty = memory_get_usage(); // Load the SplObjectStorage $start = microtime(TRUE); foreach ($docs as $d) { $sos->attach($d); } $finis = microtime(TRUE); $time_to_fill = $finis - $start; // Check membership on the object storage $start = microtime(FALSE); foreach ($docs as $d) { $sos->contains($d); } $finis = microtime(FALSE); $time_to_check = $finis - $start; $mem_spl = memory_get_usage(); $mem_used = $mem_spl - $mem_empty; printf("SplObjectStorage:\nTime to fill: %0.12f.\nTime to check: %0.12f.\nMemory: %d\n\n", $time_to_fill, $time_to_check, $mem_used); unset($sos); $mem_empty = memory_get_usage(); // Test arrays: $start = microtime(TRUE); $arr = array(); // Load the array foreach ($docs as $d) { $arr[spl_object_hash($d)] = $d; } $finis = microtime(TRUE); $time_to_fill = $finis - $start; // Check membership on the array $start = microtime(FALSE); foreach ($docs as $d) { //$arr[spl_object_hash($d)]; isset($arr[spl_object_hash($d)]); } $finis = microtime(FALSE); $time_to_check = $finis - $start; $mem_arr = memory_get_usage(); $mem_used = $mem_arr - $mem_empty; printf("Arrays:\nTime to fill: %0.12f.\nTime to check: %0.12f.\nMemory: %d\n\n", $time_to_fill, $time_to_check, $mem_used);

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
7.4.10.0150.00315.29
7.4.00.0100.01014.83
7.3.130.0100.00715.21
7.3.120.0080.01114.89
7.3.110.0090.00914.99
7.3.100.0030.01114.87
7.3.90.0070.00614.93
7.3.80.0030.01114.96
7.3.70.0050.01014.79
7.3.60.0070.01014.92
7.3.50.0100.00514.91
7.3.40.0060.00914.91
7.3.30.0070.00914.84
7.3.20.0060.01016.52
7.3.10.0060.00716.60
7.3.00.0080.00616.52
7.2.260.0100.00715.05
7.2.250.0090.00614.80
7.2.240.0060.00815.05
7.2.230.0050.00715.00
7.2.220.0080.00814.93
7.2.210.0070.00615.01
7.2.200.0100.00815.10
7.2.190.0050.00814.95
7.2.180.0060.00415.14
7.2.170.0060.00714.99
7.2.160.0050.00914.97
7.2.150.0070.00616.84
7.2.140.0050.00716.95
7.2.130.0050.01016.80
7.2.120.0090.00516.90
7.2.110.0050.00916.81
7.2.100.0090.00916.97
7.2.90.0050.01016.93
7.2.80.0050.01016.87
7.2.70.0070.00616.90
7.2.60.0040.01016.94
7.2.50.0070.00916.80
7.2.40.0080.00816.99
7.2.30.0090.00716.98
7.2.20.0080.00616.72
7.2.10.0070.00816.82
7.2.00.0050.01117.47
7.1.330.0050.01015.81
7.1.320.0050.00615.69
7.1.310.0050.01115.71
7.1.300.0040.00915.69
7.1.290.0090.00815.90
7.1.280.0030.01015.90
7.1.270.0090.00715.77
7.1.260.0040.01115.71
7.1.250.0050.01115.72
7.1.240.0060.00915.71
7.1.230.0100.00615.91
7.1.220.0000.00915.93
7.1.210.0160.00015.91
7.1.200.0040.01115.86
7.1.190.0070.00715.61
7.1.180.0060.00916.02
7.1.170.0040.01115.96
7.1.160.0070.00715.88
7.1.150.0030.00615.54
7.1.140.0060.00915.76
7.1.130.0060.00915.62
7.1.120.0070.00315.93
7.1.110.0120.00315.97
7.1.100.0030.00915.96
7.1.90.0030.00915.43
7.1.80.0030.01016.06
7.1.70.0020.00916.55
7.1.60.0050.01217.58
7.1.50.0100.00916.44
7.1.40.0070.01015.63
7.1.30.0080.00015.85
7.1.20.0060.00615.82
7.1.10.0030.01015.91
7.1.00.0030.04319.03
7.0.330.0000.01215.44
7.0.320.0080.00415.52
7.0.310.0060.00915.37
7.0.300.0000.01415.31
7.0.290.0000.01115.39
7.0.280.0070.00715.53
7.0.270.0070.00415.21
7.0.260.0030.00915.44
7.0.250.0060.00915.48
7.0.240.0060.00615.24
7.0.230.0090.00615.51
7.0.220.0040.00415.22
7.0.210.0030.00915.47
7.0.200.0050.00516.15
7.0.190.0060.01015.26
7.0.180.0040.00715.39
7.0.170.0030.01315.52
7.0.160.0040.00415.38
7.0.150.0040.00415.25
7.0.140.0040.03718.70
7.0.130.0060.00915.61
7.0.120.0150.00015.54
7.0.110.0060.00315.58
7.0.100.0230.04217.69
7.0.90.0280.04317.83
7.0.80.0080.04317.91
7.0.70.0050.04417.58
7.0.60.0070.04017.70
7.0.50.0100.04017.95
7.0.40.0100.04216.74
7.0.30.0110.04116.80
7.0.20.0070.02016.69
7.0.10.0020.05016.82
7.0.00.0100.05216.83
5.6.400.0090.00314.26
5.6.390.0040.01114.67
5.6.380.0080.00414.30
5.6.370.0090.00914.75
5.6.360.0030.01014.46
5.6.350.0090.00014.58
5.6.340.0070.00714.63
5.6.330.0130.00314.18
5.6.320.0030.01014.37
5.6.310.0000.01514.46
5.6.300.0050.00314.59
5.6.290.0040.00814.41
5.6.280.0070.03917.84
5.6.270.0000.01114.44
5.6.260.0120.00314.49
5.6.250.0070.04317.60
5.6.240.0070.04217.64
5.6.230.0050.04017.68
5.6.220.0060.03917.56
5.6.210.0100.04217.63
5.6.200.0050.04617.62
5.6.190.0110.02417.75
5.6.180.0050.04217.76
5.6.170.0030.05017.74
5.6.160.0050.04417.76
5.6.150.0050.03017.77
5.6.140.0090.04117.62
5.6.130.0110.04317.81
5.6.120.0070.04417.66
5.6.110.0080.04917.66
5.6.100.0030.03117.66
5.6.90.0040.04517.77
5.6.80.0020.03417.38
5.6.70.0050.04017.34
5.6.60.0020.04517.36
5.6.50.0030.03017.47
5.6.40.0100.03517.46
5.6.30.0070.04017.34
5.6.20.0080.04317.55
5.6.10.0080.03817.26
5.6.00.0050.04317.40
5.5.380.0070.04417.43
5.5.370.0020.03317.53
5.5.360.0120.04217.42
5.5.350.0070.04317.47
5.5.340.0030.04717.70
5.5.330.0070.03917.61
5.5.320.0100.04217.53
5.5.310.0080.02217.70
5.5.300.0120.04217.62
5.5.290.0030.04917.73
5.5.280.0080.03017.46
5.5.270.0080.04717.71
5.5.260.0110.03617.60
5.5.250.0110.03617.53
5.5.240.0080.04117.18
5.5.230.0120.03717.40
5.5.220.0080.03917.36
5.5.210.0090.04017.24
5.5.200.0030.03117.07
5.5.190.0050.04017.33
5.5.180.0080.04017.26
5.5.170.0030.01014.28
5.5.160.0080.04217.14
5.5.150.0050.04017.15
5.5.140.0090.03617.34
5.5.130.0070.04317.31
5.5.120.0070.04917.29
5.5.110.0100.03517.16
5.5.100.0100.04017.03
5.5.90.0050.04917.21
5.5.80.0080.04317.18
5.5.70.0050.03817.32
5.5.60.0100.03517.16
5.5.50.0000.03117.27
5.5.40.0060.03917.29
5.5.30.0050.04417.27
5.5.20.0080.04017.26
5.5.10.0040.04617.21
5.5.00.0090.04117.27
5.4.450.0060.04215.57
5.4.440.0060.03815.61
5.4.430.0000.05115.61
5.4.420.0030.04015.64
5.4.410.0070.04015.68
5.4.400.0110.03615.48
5.4.390.0050.02415.56
5.4.380.0070.03715.57
5.4.370.0090.02215.48
5.4.360.0050.04315.53
5.4.350.0050.04315.41
5.4.340.0050.03815.52
5.4.330.0060.00612.00
5.4.320.0030.04315.49
5.4.310.0070.04015.55
5.4.300.0000.02715.53
5.4.290.0070.03315.51
5.4.280.0060.03815.53
5.4.270.0050.03115.51
5.4.260.0050.03415.45
5.4.250.0020.03215.53
5.4.240.0080.04115.39
5.4.230.0080.02715.51
5.4.220.0060.03115.59
5.4.210.0100.03815.42
5.4.200.0070.04015.61
5.4.190.0070.04215.39
5.4.180.0100.03315.53
5.4.170.0080.04015.47
5.4.160.0030.02615.38
5.4.150.0080.02915.51
5.4.140.0030.03714.14
5.4.130.0030.02614.15
5.4.120.0060.04314.17
5.4.110.0060.03314.14
5.4.100.0000.02614.15
5.4.90.0040.04014.13
5.4.80.0020.04714.24
5.4.70.0050.04214.18
5.4.60.0050.03714.12
5.4.50.0080.03714.11
5.4.40.0030.03014.19
5.4.30.0050.02414.20
5.4.20.0070.03514.09
5.4.10.0070.03714.07
5.4.00.0070.03913.83
5.3.290.0020.04313.33
5.3.280.0080.04013.31
5.3.270.0070.03413.29
5.3.260.0080.03813.29
5.3.250.0030.04213.30
5.3.240.0080.03613.31
5.3.230.0030.04213.29
5.3.220.0080.03613.29
5.3.210.0100.03413.22
5.3.200.0030.03813.31
5.3.190.0090.03613.30
5.3.180.0060.03713.22
5.3.170.0080.03713.29
5.3.160.0030.04413.30
5.3.150.0030.04013.21
5.3.140.0070.03813.29
5.3.130.0020.04213.20
5.3.120.0120.03813.28
5.3.110.0070.04013.26
5.3.100.0090.03113.00
5.3.90.0050.03213.01
5.3.80.0080.04012.97
5.3.70.0080.04013.02
5.3.60.0030.02812.99
5.3.50.0060.03312.98
5.3.40.0060.03112.99
5.3.30.0030.04012.96
5.3.20.0020.04212.85
5.3.10.0080.03812.82
5.3.00.0000.04412.81
5.2.170.0030.06711.13
5.2.160.0030.05711.13
5.2.150.0100.06311.21
5.2.140.0070.06011.13
5.2.130.0030.05311.17
5.2.120.0130.05311.13
5.2.110.0070.06011.18
5.2.100.0170.05311.13
5.2.90.0030.06311.16
5.2.80.0030.06711.16
5.2.70.0070.06011.13
5.2.60.0070.05711.13
5.2.50.0070.04711.13
5.2.40.0030.06011.13
5.2.30.0070.06011.13
5.2.20.0000.04711.13
5.2.10.0000.03311.13
5.2.00.0070.06011.13
5.1.60.0100.05011.13
5.1.50.0000.05711.13
5.1.40.0100.02311.13
5.1.30.0070.05311.13
5.1.20.0070.04011.13
5.1.10.0030.05311.13
5.1.00.0030.05711.13
5.0.50.0030.04711.13
5.0.40.0000.03711.13
5.0.30.0000.06711.13
5.0.20.0030.04311.13
5.0.10.0000.04711.13
5.0.00.0000.05311.13
4.4.90.0030.03711.13
4.4.80.0000.03011.13
4.4.70.0000.03711.13
4.4.60.0030.03311.13
4.4.50.0030.01711.13
4.4.40.0070.05011.13
4.4.30.0030.03711.13
4.4.20.0000.03311.13
4.4.10.0000.03711.13
4.4.00.0070.03011.13
4.3.110.0000.03311.13
4.3.100.0030.03011.13
4.3.90.0070.01011.13
4.3.80.0000.05311.13
4.3.70.0000.01311.13
4.3.60.0000.03311.13
4.3.50.0030.03011.13
4.3.40.0070.04311.13
4.3.30.0000.03311.13
4.3.20.0000.03711.13
4.3.10.0000.01311.13
4.3.00.0000.01311.13

preferences:
31.82 ms | 401 KiB | 5 Q