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.30.0110.00017.68
8.1.20.0030.01317.55
8.1.10.0150.00917.43
8.1.00.0160.00817.40
8.0.160.0120.00616.91
8.0.150.0080.00516.96
8.0.140.0000.01117.00
8.0.130.0130.00416.77
8.0.120.0160.00016.92
8.0.110.0100.00516.95
8.0.100.0080.00816.85
8.0.90.0110.00316.95
8.0.80.0040.00417.04
8.0.70.0110.00316.88
8.0.60.0160.00416.91
8.0.50.0220.00016.96
8.0.30.0120.00616.92
8.0.20.0120.00917.04
8.0.10.0140.00917.16
8.0.00.0070.00717.12
7.4.280.0180.00716.54
7.4.270.0180.00616.55
7.4.260.0190.00316.63
7.4.250.0180.00616.55
7.4.240.0130.01216.38
7.4.230.0220.00016.55
7.4.220.0160.00416.41
7.4.210.0100.00716.52
7.4.200.0070.01216.65
7.4.190.0150.00416.51
7.4.180.0090.00916.70
7.4.160.0100.00816.66
7.4.150.0100.00916.59
7.4.140.0090.00716.42
7.4.130.0090.01016.53
7.4.120.0090.00916.45
7.4.110.0060.01116.49
7.4.100.0130.00416.52
7.4.90.0120.00416.49
7.4.80.0130.00116.44
7.4.70.0110.00816.46
7.4.60.0080.00816.43
7.4.50.0110.00416.35
7.4.40.0100.00716.29
7.4.30.0060.01016.29
7.4.20.0120.00116.34
7.4.10.0050.00716.52
7.4.00.0080.00316.48
7.3.330.0140.00516.17
7.3.320.0200.00016.20
7.3.310.0140.00516.38
7.3.300.0130.00716.38
7.3.290.0200.00016.19
7.3.280.0110.00716.42
7.3.270.0160.00216.32
7.3.260.0130.00716.29
7.3.250.0120.00816.40
7.3.240.0130.00616.36
7.3.230.0080.00916.35
7.3.220.0080.00916.36
7.3.210.0110.00616.35
7.3.200.0090.00716.40
7.3.190.0170.00016.37
7.3.180.0140.00516.36
7.3.170.0130.00316.38
7.3.160.0100.00716.25
7.3.150.0110.00616.22
7.3.140.0120.00516.38
7.3.130.0110.00516.24
7.3.120.0140.00316.39
7.3.110.0110.00616.36
7.3.100.0070.01016.18
7.3.90.0130.00316.53
7.3.80.0130.00316.36
7.3.70.0140.00316.32
7.3.60.0130.00416.46
7.3.50.0100.00616.41
7.3.40.0110.00616.32
7.3.30.0120.00515.70
7.3.20.0110.00516.57
7.3.10.0180.00716.34
7.3.00.0430.00816.34
7.2.340.0170.00616.27
7.2.330.0140.00916.30
7.2.320.0160.00916.29
7.2.310.0250.00216.27
7.2.300.0150.00716.42
7.2.290.0130.01016.31
7.2.280.0140.00916.33
7.2.270.0150.00716.32
7.2.260.0160.00716.46
7.2.250.0140.00816.28
7.2.240.0130.01016.28
7.2.230.0160.00716.40
7.2.220.0150.00816.38
7.2.210.0150.00816.29
7.2.200.0190.00716.48
7.2.190.0180.00516.40
7.2.180.0180.00316.48
7.2.170.0170.00516.48
7.2.160.0180.00615.86
7.2.150.0300.00616.30
7.2.140.0390.00516.51
7.2.130.0170.00416.73
7.2.120.0230.00516.75
7.2.110.0680.00516.66
7.2.100.0170.00616.61
7.2.90.1060.00816.50
7.2.80.0630.01016.64
7.2.70.0630.00916.60
7.2.60.0790.00816.54
7.2.50.0770.00416.59
7.2.40.0770.00616.58
7.2.30.0460.01116.55
7.2.20.0440.00616.43
7.2.10.0690.00816.55
7.2.00.0710.01017.23
7.1.330.0150.00516.55
7.1.320.0130.00716.40
7.1.310.0150.00616.35
7.1.300.0170.00716.47
7.1.290.0140.00816.38
7.1.280.0160.00416.46
7.1.270.0200.00415.56
7.1.260.0870.00515.49
7.1.250.0160.00715.50
7.1.240.0720.00815.55
7.1.230.1140.00515.61
7.1.220.0470.00615.70
7.1.210.0360.00415.48
7.1.200.1530.00515.58
7.1.190.0720.00715.56
7.1.180.1090.00515.54
7.1.170.0820.00515.59
7.1.160.1190.00615.53
7.1.150.0760.00315.57
7.1.140.0540.00715.56
7.1.130.0760.00715.60
7.1.120.0480.01016.45
7.1.110.0680.00716.08
7.1.100.0560.00816.14
7.1.90.0340.01016.07
7.1.80.0320.01016.16
7.1.70.0290.00816.08
7.1.60.0200.00919.84
7.1.50.0290.00719.57
7.1.40.0320.00720.12
7.1.30.0390.00920.28
7.1.20.0330.00720.21
7.1.10.0290.00715.82
7.1.00.0200.02017.04
7.0.330.0440.00715.21
7.0.320.0280.00615.12
7.0.310.0840.00915.11
7.0.300.0580.00815.17
7.0.290.0820.00615.09
7.0.280.0820.01015.17
7.0.270.0910.00715.11
7.0.260.0440.01315.92
7.0.250.0520.01015.93
7.0.240.0620.00715.89
7.0.230.0310.01215.91
7.0.220.0140.00615.94
7.0.210.0340.00515.57
7.0.200.0590.00915.82
7.0.190.0380.00415.62
7.0.180.0350.00915.53
7.0.170.0310.00715.50
7.0.160.0310.00815.43
7.0.150.0340.00715.39
7.0.140.0230.02116.76
7.0.130.0220.00815.54
7.0.120.0300.00815.68
7.0.110.0270.00415.38
7.0.100.0280.00415.52
7.0.90.0250.00815.47
7.0.80.0240.00615.36
7.0.70.0290.00515.42
7.0.60.0260.01716.25
7.0.50.0270.01616.44
7.0.40.0770.02316.53
7.0.30.0230.01916.46
7.0.20.0200.01716.49
7.0.10.0260.01716.49
7.0.00.0210.01816.49
5.6.400.0130.00915.34
5.6.390.0160.00815.41
5.6.380.0170.00915.31
5.6.370.0180.00215.38
5.6.360.0110.00915.37
5.6.350.0130.00715.40
5.6.340.0150.00715.41
5.6.330.0140.00715.53
5.6.320.0140.01015.42
5.6.310.0140.00815.47
5.6.300.0120.02316.69
5.6.290.0170.02016.79
5.6.280.0150.02817.63
5.6.270.0120.02216.73
5.6.260.0110.02416.76
5.6.250.0170.01716.76
5.6.240.0170.01716.72
5.6.230.0180.01816.71
5.6.220.0160.02016.79
5.6.210.0150.02617.47
5.6.200.0150.03217.71
5.6.190.0120.02817.71
5.6.180.0180.02417.68
5.6.170.0150.02517.67
5.6.160.0160.03017.60
5.6.150.0100.02917.67
5.6.140.0130.02717.65
5.6.130.0160.02717.59
5.6.120.0120.03017.68
5.6.110.0140.03117.64
5.6.100.0130.02917.63
5.6.90.0140.03217.63
5.6.80.0160.02717.29
5.6.70.0100.03517.35
5.6.60.0120.02917.37
5.6.50.0190.02117.30
5.6.40.0110.02917.26
5.6.30.0120.02817.34
5.6.20.0130.03117.33
5.6.10.0120.03217.31
5.6.00.0120.02917.26
5.5.380.0130.01815.92
5.5.370.0140.01615.97
5.5.360.0120.02615.77
5.5.350.0140.03416.70
5.5.340.0100.02816.96
5.5.330.0130.03016.97
5.5.320.0130.02817.00
5.5.310.0120.03216.96
5.5.300.0180.02316.82
5.5.290.0150.03416.86
5.5.280.0120.02916.96
5.5.270.0130.03316.91
5.5.260.0210.02916.91
5.5.250.0150.03116.88
5.5.240.0180.02516.67
5.5.230.0130.02916.61
5.5.220.0110.03116.67
5.5.210.0120.02616.61
5.5.200.0160.02416.62
5.5.190.0160.02616.65
5.5.180.0150.02316.70
5.5.170.0160.00815.06
5.5.160.0110.02816.46
5.5.150.0110.02916.58
5.5.140.0090.03216.52
5.5.130.0130.03016.55
5.5.120.0130.02516.59
5.5.110.0130.02616.54
5.5.100.0160.03316.65
5.5.90.0190.02816.64
5.5.80.0140.02816.65
5.5.70.0140.02516.64
5.5.60.0150.02416.64
5.5.50.0150.02616.67
5.5.40.0130.02216.52
5.5.30.0160.02416.55
5.5.20.0120.03016.57
5.5.10.0120.03016.62
5.5.00.0160.02816.65
5.4.450.0100.03015.14
5.4.440.0110.03115.12
5.4.430.0110.02515.14
5.4.420.0120.03015.11
5.4.410.0090.03115.10
5.4.400.0110.02714.95
5.4.390.0100.02715.01
5.4.380.0130.02615.05
5.4.370.0120.02214.98
5.4.360.0100.03115.00
5.4.350.0100.02815.01
5.4.340.0100.03015.04
5.4.330.0210.00212.30
5.4.320.0080.02715.08
5.4.310.0110.02615.02
5.4.300.0120.02315.09
5.4.290.0100.02614.96
5.4.280.0110.02615.02
5.4.270.0140.02415.02
5.4.260.0100.02315.00
5.4.250.0130.02614.95
5.4.240.0120.02514.96
5.4.230.0080.02714.91
5.4.220.0110.02614.94
5.4.210.0120.02314.90
5.4.200.0110.02514.94
5.4.190.0090.03214.93
5.4.180.0130.02814.91
5.4.170.0120.02815.03
5.4.160.0130.02015.02
5.4.150.0100.03014.97
5.4.140.0100.02513.94
5.4.130.0100.02313.93
5.4.120.0110.02713.90
5.4.110.0120.02414.01
5.4.100.0080.02814.01
5.4.90.0100.02113.97
5.4.80.0140.02613.99
5.4.70.0090.02514.02
5.4.60.0070.03014.04
5.4.50.0090.03213.95
5.4.40.0100.03014.02
5.4.30.0120.02314.05
5.4.20.0120.02414.03
5.4.10.0110.02513.92
5.4.00.0080.03113.70
5.3.290.0100.02513.48
5.3.280.0090.02313.48
5.3.270.0100.02513.38
5.3.260.0110.02413.46
5.3.250.0090.02913.47
5.3.240.0100.02713.37
5.3.230.0100.02413.37
5.3.220.0100.02413.37
5.3.210.0140.02613.33
5.3.200.0110.02413.32
5.3.190.0110.02513.41
5.3.180.0100.02513.37
5.3.170.0120.02713.46
5.3.160.0110.02513.36
5.3.150.0110.02913.41
5.3.140.0090.02713.38
5.3.130.0100.02513.35
5.3.120.0130.02513.34
5.3.110.0110.02313.41
5.3.100.0110.02413.18
5.3.90.0090.02813.17
5.3.80.0070.03013.10
5.3.70.0100.02513.14
5.3.60.0080.02613.11
5.3.50.0120.02213.08
5.3.40.0090.02613.08
5.3.30.0090.02313.24
5.3.20.0130.02013.04
5.3.10.0100.02212.92
5.3.00.0100.02212.89

preferences:
43.46 ms | 401 KiB | 5 Q