3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Object hashing tests. */ $sos = new SplObjectStorage(); $usage = "php %s INTEGER \t - Run the SPLObjectStorage vs. Array test with INTEGER size.\n"; if (count($argv) < 2) { printf($usage, $argv[0]); exit(1); } $docs = array(); $iterations = (int)$argv[1]; //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)
8.1.120.0030.00718.73
8.1.110.0120.00618.74
8.1.100.0060.00918.66
8.1.90.0120.00318.76
8.1.80.0100.00518.75
8.1.70.0110.00317.87
8.1.60.0090.00918.86
8.1.50.0120.00818.78
8.1.40.0110.00418.79
8.1.30.0100.00718.63
8.1.20.0150.00318.79
8.1.10.0140.00518.74
8.1.00.0170.00518.80
8.0.250.0080.00518.13
8.0.240.0130.00318.11
8.0.230.0080.00817.98
8.0.220.0050.01017.94
8.0.210.0080.00818.07
8.0.200.0120.00418.09
8.0.190.0040.01118.11
8.0.180.0120.00218.17
8.0.170.0120.00318.21
8.0.160.0100.00518.13
8.0.150.0140.00018.16
8.0.140.0080.00818.11
8.0.130.0140.00318.03
8.0.120.0130.00317.99
8.0.110.0120.00518.03
8.0.100.0050.00817.60
8.0.90.0070.00517.58
8.0.80.0060.00417.39
8.0.70.0080.00417.53
8.0.60.0070.00417.54
8.0.50.0080.00317.56
8.0.30.0150.00617.36
8.0.20.0140.00517.42
8.0.10.0170.00517.46
8.0.00.0120.00517.52
7.4.330.0140.00013.98
7.4.320.0060.00617.61
7.4.300.0030.00617.62
7.4.290.0000.01017.65
7.4.280.0000.01017.60
7.4.270.0070.00317.74
7.4.260.0000.01017.74
7.4.250.0110.00317.77
7.4.240.0060.00917.70
7.4.230.0050.00717.22
7.4.220.0050.00517.02
7.4.210.0040.00617.06
7.4.200.0060.00416.97
7.4.190.0060.00417.12
7.4.180.0060.00417.23
7.4.160.0120.00416.95
7.4.150.0120.00516.82
7.4.140.0140.00116.88
7.4.130.0090.00816.80
7.4.120.0110.00516.78
7.4.110.0090.00716.66
7.4.100.0100.00516.92
7.4.90.0100.00516.93
7.4.80.0100.00416.78
7.4.70.0110.00416.69
7.4.60.0090.00616.79
7.4.50.0090.00616.77
7.4.40.0090.00716.67
7.4.30.0130.00316.76
7.4.20.0100.00616.81
7.4.10.0080.00716.73
7.4.00.0100.00615.86
7.3.330.0110.00417.40
7.3.320.0100.00317.54
7.3.310.0120.00317.43
7.3.300.0060.00517.03
7.3.290.0030.00716.86
7.3.280.0100.00616.71
7.3.270.0130.00316.74
7.3.260.0110.00416.66
7.3.250.0150.00416.74
7.3.240.0110.00716.67
7.3.230.0120.00616.68
7.3.220.0110.00716.70
7.3.210.0120.00516.73
7.3.200.0140.00616.69
7.3.190.0130.00816.70
7.3.180.0140.00416.69
7.3.170.0130.00416.67
7.3.160.0130.00416.72
7.3.150.0190.00116.70
7.3.140.0120.00516.71
7.3.130.0090.00816.70
7.3.120.0110.00815.73
7.3.110.0090.00915.63
7.3.100.0090.00915.65
7.3.90.0080.00815.74
7.3.80.0090.00615.57
7.3.70.0100.00715.63
7.3.60.0070.00815.69
7.3.50.0050.00915.67
7.3.40.0060.00815.62
7.3.30.0060.00815.60
7.3.20.0110.00517.12
7.3.10.0070.00816.98
7.3.00.0110.00516.88
7.2.340.0120.00716.72
7.2.330.0170.00216.68
7.2.320.0080.00916.75
7.2.310.0090.00916.70
7.2.300.0130.00616.72
7.2.290.0110.00516.78
7.2.280.0130.00616.68
7.2.270.0130.00616.70
7.2.260.0120.00616.71
7.2.250.0060.01115.86
7.2.240.0100.00915.82
7.2.230.0090.00815.70
7.2.220.0100.00715.77
7.2.210.0100.00715.77
7.2.200.0080.00815.76
7.2.190.0090.00415.73
7.2.180.0070.00815.85
7.2.170.0070.00815.83
7.2.160.0060.01016.39
7.2.150.0150.00617.31
7.2.140.0090.00617.36
7.2.130.0080.00817.53
7.2.120.0090.00617.47
7.2.110.0110.00617.50
7.2.100.0050.01017.39
7.2.90.0070.01117.40
7.2.80.0120.00717.43
7.2.70.0100.00717.34
7.2.60.0120.00417.35
7.2.50.0100.00717.37
7.2.40.0080.01017.39
7.2.30.0100.00517.38
7.2.20.0100.00817.41
7.2.10.0090.00717.46
7.2.00.0080.00718.17
7.1.330.0110.00616.04
7.1.320.0070.00716.05
7.1.310.0080.00916.05
7.1.300.0100.00616.11
7.1.290.0090.00616.12
7.1.280.0080.00616.07
7.1.270.0080.00716.02
7.1.260.0070.00816.06
7.1.250.0090.00616.29
7.1.240.0100.00516.25
7.1.230.0120.00516.36
7.1.220.0080.00716.37
7.1.210.0070.01016.38
7.1.200.0080.00716.28
7.1.190.0110.00316.24
7.1.180.0100.00516.21
7.1.170.0120.00516.31
7.1.160.0080.00616.27
7.1.150.0070.00716.25
7.1.140.0080.00516.26
7.1.130.0080.00616.16
7.1.120.0050.00916.71
7.1.110.0080.00716.66
7.1.100.0090.00716.64
7.1.90.0090.00716.60
7.1.80.0080.00616.64
7.1.70.0090.00716.46
7.1.60.0120.00719.92
7.1.50.0130.00719.48
7.1.40.0130.00519.80
7.1.30.0110.00619.87
7.1.20.0110.00819.89
7.1.10.0100.00816.25
7.1.00.0060.01917.37
7.0.330.0100.00715.77
7.0.320.0080.00715.84
7.0.310.0110.00615.85
7.0.300.0090.00615.85
7.0.290.0110.00215.68
7.0.280.0060.00815.82
7.0.270.0080.00515.83
7.0.260.0080.00616.31
7.0.250.0090.00416.42
7.0.240.0120.00616.34
7.0.230.0100.00416.39
7.0.220.0100.00516.31
7.0.210.0080.00616.10
7.0.200.0120.00616.11
7.0.190.0080.00716.19
7.0.180.0090.00715.99
7.0.170.0110.00315.99
7.0.160.0070.00715.96
7.0.150.0060.00815.92
7.0.140.0060.01916.90
7.0.130.0100.00416.13
7.0.120.0100.00416.04
7.0.110.0080.00615.93
7.0.100.0100.00515.97
7.0.90.0040.01015.86
7.0.80.0090.00515.93
7.0.70.0090.00515.87
7.0.60.0070.01616.52
7.0.50.0110.01616.64
7.0.40.0120.01516.40
7.0.30.0090.01816.38
7.0.20.0090.01916.31
7.0.10.0090.01416.44
7.0.00.0090.01816.33
5.6.400.0060.00815.84
5.6.390.0100.00615.75
5.6.380.0100.00515.86
5.6.370.0090.00615.68
5.6.360.0060.00915.76
5.6.350.0090.00515.88
5.6.340.0100.00515.83
5.6.330.0080.00715.85
5.6.320.0120.00515.82
5.6.310.0110.00715.62
5.6.300.0090.01816.68
5.6.290.0110.01616.82
5.6.280.0110.02617.48
5.6.270.0080.02016.76
5.6.260.0110.01516.82
5.6.250.0120.01616.79
5.6.240.0090.01616.89
5.6.230.0100.01616.80
5.6.220.0100.01716.80
5.6.210.0100.02317.46
5.6.200.0100.02917.60
5.6.190.0090.03017.56
5.6.180.0110.02317.55
5.6.170.0130.02217.56
5.6.160.0120.02717.60
5.6.150.0100.02817.55
5.6.140.0150.02517.54
5.6.130.0110.02617.57
5.6.120.0110.02617.49
5.6.110.0130.02717.53
5.6.100.0100.02617.53
5.6.90.0110.02517.57
5.6.80.0120.02217.33
5.6.70.0100.01616.70
5.6.60.0090.01516.75
5.6.50.0080.01716.54
5.6.40.0090.01416.68
5.6.30.0100.01616.61
5.6.20.0120.01616.61
5.6.10.0120.01516.67
5.6.00.0090.01516.65
5.5.380.0090.02116.59
5.5.370.0170.01416.50
5.5.360.0120.01816.46
5.5.350.0170.02617.21
5.5.340.0110.02917.47
5.5.330.0100.03317.43
5.5.320.0120.03017.50
5.5.310.0120.02517.43
5.5.300.0130.02717.42
5.5.290.0140.02817.41
5.5.280.0170.02417.40
5.5.270.0140.02717.41
5.5.260.0100.02917.40
5.5.250.0110.02717.38
5.5.240.0080.03217.18
5.5.230.0140.01816.47
5.5.220.0100.01816.47
5.5.210.0100.01916.60
5.5.200.0140.01716.40
5.5.190.0140.01516.24
5.5.180.0070.02916.45
5.5.170.0170.00415.95
5.5.160.0100.01816.37
5.5.150.0150.01516.33
5.5.140.0100.02116.29
5.5.130.0130.01516.24
5.5.120.0140.01816.25
5.5.110.0110.02316.26
5.5.100.0110.02216.43
5.5.90.0120.01516.46
5.5.80.0120.01816.50
5.5.70.0110.01916.47
5.5.60.0100.01916.43
5.5.50.0110.02216.45
5.5.40.0100.01816.39
5.5.30.0110.01616.41
5.5.20.0110.02116.44
5.5.10.0120.02216.41
5.5.00.0120.01916.35
5.4.450.0140.02215.55
5.4.440.0120.02615.61
5.4.430.0130.02215.55
5.4.420.0130.02515.58
5.4.410.0110.02215.53
5.4.400.0120.02515.38
5.4.390.0100.02915.46
5.4.380.0120.02615.48
5.4.370.0090.02615.43
5.4.360.0090.03315.43
5.4.350.0110.02515.49
5.4.340.0100.02415.48
5.4.330.0100.00513.02
5.4.320.0130.02115.41
5.4.310.0100.02715.41
5.4.300.0090.02615.50
5.4.290.0100.02415.45
5.4.280.0100.02515.46
5.4.270.0130.02715.42
5.4.260.0120.03015.41
5.4.250.0120.02315.47
5.4.240.0120.02515.51
5.4.230.0080.03115.38
5.4.220.0130.03115.34
5.4.210.0140.02915.38
5.4.200.0110.02515.38
5.4.190.0120.02815.35
5.4.180.0140.02615.34
5.4.170.0110.03015.46
5.4.160.0110.02815.40
5.4.150.0150.02015.44
5.4.140.0150.02314.43
5.4.130.0100.02414.44
5.4.120.0140.02314.34
5.4.110.0070.03314.39
5.4.100.0070.02814.42
5.4.90.0080.02414.40
5.4.80.0140.01914.41
5.4.70.0090.02714.37
5.4.60.0080.02914.42
5.4.50.0110.02414.30
5.4.40.0090.02614.39
5.4.30.0070.02814.45
5.4.20.0080.03014.42
5.4.10.0130.02214.45
5.4.00.0120.02314.04
5.3.290.0100.02713.85
5.3.280.0080.02813.74
5.3.270.0110.02913.90
5.3.260.0110.02613.92
5.3.250.0100.02413.80
5.3.240.0120.02213.79
5.3.230.0110.02713.82
5.3.220.0080.02413.75
5.3.210.0090.02513.81
5.3.200.0060.02813.77
5.3.190.0060.02713.78
5.3.180.0110.02813.80
5.3.170.0120.02213.81
5.3.160.0060.03113.83
5.3.150.0080.03113.86
5.3.140.0100.02613.91
5.3.130.0140.02913.80
5.3.120.0120.02713.80
5.3.110.0100.02813.81
5.3.100.0100.02513.55
5.3.90.0080.02313.53
5.3.80.0100.02213.52
5.3.70.0110.02413.47
5.3.60.0110.02513.64
5.3.50.0100.02213.55
5.3.40.0130.02213.53
5.3.30.0070.02513.55
5.3.20.0110.02413.42
5.3.10.0090.02513.36
5.3.00.0080.03113.37

preferences:
43.24 ms | 401 KiB | 5 Q