3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Object hashing tests. */ $sos = new SplObjectStorage(); $docs = array(); $iterations = (int) 10000; //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.2.00.0040.01925.60
7.1.70.0070.01023.38
7.1.60.0100.04023.52
7.1.50.0100.03823.29
7.1.00.0070.07028.51
7.0.200.0070.01323.04
7.0.140.0130.08328.23
7.0.110.0000.06027.29
7.0.100.0030.05727.26
7.0.90.0100.04727.25
7.0.80.0130.04327.27
7.0.70.0100.05327.26
7.0.60.0030.06027.34
7.0.50.0070.05027.86
7.0.40.0130.06022.66
7.0.30.0070.10022.56
7.0.20.0100.06722.45
7.0.10.0170.08722.48
7.0.00.0130.09322.45
5.6.280.0030.10729.11
5.6.260.0070.06028.68
5.6.250.0030.06328.61
5.6.240.0130.09728.81
5.6.230.0070.06028.65
5.6.220.0130.07028.50
5.6.210.0030.08328.54
5.6.200.0130.07729.09
5.6.190.0070.06329.07
5.6.180.0170.05029.11
5.6.170.0100.10029.10
5.6.160.0070.11029.03
5.6.150.0170.10328.95
5.6.140.0170.10029.14
5.6.130.0070.12329.21
5.6.120.0070.11329.24
5.6.110.0000.11328.92
5.6.100.0170.09728.90
5.6.90.0070.10329.00
5.6.80.0070.12028.59
5.6.70.0100.12330.13
5.6.60.0130.12330.39
5.6.50.0300.10330.31
5.6.40.0200.10030.36
5.6.30.0200.10730.08
5.6.20.0200.08730.42
5.6.10.0170.10330.27
5.6.00.0070.11730.41
5.5.380.0100.10328.49
5.5.370.0070.06028.49
5.5.360.0070.06028.48
5.5.350.0100.05728.43
5.5.340.0070.07729.02
5.5.330.0030.06328.69
5.5.320.0170.05329.04
5.5.310.0030.07028.84
5.5.300.0130.10328.97
5.5.290.0000.12728.90
5.5.280.0100.11729.04
5.5.270.0070.10328.76
5.5.260.0070.11028.80
5.5.250.0100.10328.50
5.5.240.0070.10728.41
5.5.230.0230.10330.22
5.5.220.0100.10330.09
5.5.210.0200.11030.05
5.5.200.0170.11330.06
5.5.190.0300.09329.96
5.5.180.0100.11730.05
5.5.160.0070.11729.96
5.5.150.0130.09330.02
5.5.140.0100.12330.10
5.5.130.0070.12030.01
5.5.120.0100.12030.11
5.5.110.0200.09330.04
5.5.100.0130.10729.79
5.5.90.0130.10030.00
5.5.80.0100.10729.82
5.5.70.0130.11029.96
5.5.60.0130.11029.84
5.5.50.0130.10729.82
5.5.40.0100.10329.87
5.5.30.0170.10029.79
5.5.20.0130.10729.79
5.5.10.0230.10329.91
5.5.00.0170.11029.84
5.4.450.0130.09329.04
5.4.440.0070.11329.00
5.4.430.0100.11729.04
5.4.420.0030.12029.00
5.4.410.0130.10728.90
5.4.400.0030.11328.61
5.4.390.0130.08028.86
5.4.380.0130.11729.02
5.4.370.0100.11328.76
5.4.360.0170.08328.84
5.4.350.0100.10328.84
5.4.340.0200.10728.86
5.4.320.0200.11328.71
5.4.310.0270.09728.63
5.4.300.0030.12028.63
5.4.290.0100.07728.77
5.4.280.0130.10328.64
5.4.270.0100.10728.73
5.4.260.0170.10728.64
5.4.250.0030.11028.68
5.4.240.0100.10728.59
5.4.230.0170.09728.72
5.4.220.0070.10728.73
5.4.210.0100.10728.62
5.4.200.0070.11328.82
5.4.190.0170.11028.70
5.4.180.0100.12328.92
5.4.170.0200.11028.60
5.4.160.0070.11028.74
5.4.150.0130.11028.91
5.4.140.0130.10326.00
5.4.130.0200.09726.14
5.4.120.0100.11025.89
5.4.110.0130.11026.16
5.4.100.0130.10326.21
5.4.90.0100.11025.91
5.4.80.0070.11326.07
5.4.70.0130.10326.20
5.4.60.0100.11726.10
5.4.50.0070.10325.95
5.4.40.0030.11326.18
5.4.30.0030.09725.87
5.4.20.0170.09326.16
5.4.10.0200.10325.95
5.4.00.0130.09725.61
5.3.290.0070.12025.85
5.3.280.0070.13025.96
5.3.270.0130.12025.76
5.3.260.0200.08025.89
5.3.250.0070.09325.82
5.3.240.0170.12325.90
5.3.230.0130.11025.92
5.3.220.0030.11725.93
5.3.210.0130.10325.93
5.3.200.0130.11025.62
5.3.190.0070.11325.85
5.3.180.0170.09725.78
5.3.170.0130.12025.70
5.3.160.0100.11025.94
5.3.150.0130.11325.78
5.3.140.0170.07725.84
5.3.130.0100.11025.82
5.3.120.0030.12025.76
5.3.110.0170.11025.82
5.3.100.0070.12725.15
5.3.90.0200.11025.14
5.3.80.0130.10725.05
5.3.70.0130.10725.24
5.3.60.0100.09325.31
5.3.50.0070.11725.09
5.3.40.0130.11725.16
5.3.30.0200.10023.11
5.3.20.0130.09022.92
5.3.10.0200.10323.11
5.3.00.0070.07723.00
5.2.170.0170.09319.10
5.2.160.0130.08719.09
5.2.150.0000.11019.08
5.2.140.0100.08319.34
5.2.130.0170.08719.02
5.2.120.0130.09719.06
5.2.110.0130.09319.03
5.2.100.0100.09319.15
5.2.90.0200.08719.06
5.2.80.0030.10319.06
5.2.70.0030.11319.04
5.2.60.0200.08719.14
5.2.50.0130.08319.06
5.2.40.0100.10018.96
5.2.30.0130.10018.86
5.2.20.0170.11019.18
5.2.10.0130.08018.82
5.2.00.0100.06717.39
5.1.60.0170.05718.36
5.1.50.0030.04018.21
5.1.40.0070.07018.20
5.1.30.0100.06718.46
5.1.20.0100.06318.56
5.1.10.0030.04718.54
5.1.00.0070.07018.34
5.0.50.0070.04311.70
5.0.40.0030.04311.70
5.0.30.0030.06711.70
5.0.20.0070.03711.70
5.0.10.0000.04711.70
5.0.00.0030.06011.70
4.4.90.0100.02711.70
4.4.80.0030.03011.70
4.4.70.0000.03711.70
4.4.60.0030.03311.70
4.4.50.0030.03711.70
4.4.40.0070.05011.70
4.4.30.0030.03711.70
4.4.20.0070.03011.70
4.4.10.0030.02011.70
4.4.00.0000.05711.70
4.3.110.0000.03711.70
4.3.100.0000.03011.70
4.3.90.0000.03711.70
4.3.80.0000.03311.70
4.3.70.0000.03711.70
4.3.60.0070.03011.70
4.3.50.0000.03711.70
4.3.40.0000.05311.70
4.3.30.0000.03711.70
4.3.20.0000.03311.70
4.3.10.0000.03311.70
4.3.00.0030.03311.70

preferences:
37.99 ms | 400 KiB | 5 Q