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)
7.4.10.0090.00314.80
7.4.00.0070.01315.03
7.3.130.0030.01315.00
7.3.120.0070.00714.83
7.3.110.0070.01115.04
7.3.100.0000.01414.79
7.3.90.0070.00715.03
7.3.80.0070.00714.93
7.3.70.0030.00614.55
7.3.60.0100.00314.85
7.3.50.0080.01114.68
7.3.40.0000.00914.71
7.3.30.0150.00014.41
7.3.20.0070.00416.38
7.3.10.0020.01216.71
7.3.00.0040.00816.62
7.2.260.0030.01614.98
7.2.250.0090.00614.96
7.2.240.0040.01215.19
7.2.230.0070.01014.82
7.2.220.0000.01515.02
7.2.210.0000.01315.20
7.2.200.0000.01315.00
7.2.190.0080.00815.00
7.2.180.0060.01014.99
7.2.170.0040.01114.99
7.2.160.0030.00714.97
7.2.150.0000.01516.84
7.2.140.0040.01116.84
7.2.130.0100.00716.88
7.2.120.0120.00516.70
7.2.110.0030.01116.74
7.2.100.0030.00916.79
7.2.90.0070.01116.94
7.2.80.0050.01216.82
7.2.70.0060.00817.03
7.2.60.0080.01016.83
7.2.50.0050.01016.96
7.2.40.0070.01316.87
7.2.30.0100.00916.91
7.2.20.0120.00916.73
7.2.10.0140.00716.89
7.2.00.0090.01016.82
7.1.330.0060.00915.85
7.1.320.0080.00315.74
7.1.310.0080.00015.47
7.1.300.0070.00715.77
7.1.290.0040.01515.81
7.1.280.0000.01215.76
7.1.270.0070.00715.79
7.1.260.0000.01615.86
7.1.250.0030.01215.73
7.1.240.0070.01115.80
7.1.230.0140.00015.95
7.1.220.0030.01015.62
7.1.210.0000.01315.88
7.1.200.0090.00915.63
7.1.190.0060.00615.76
7.1.180.0030.01315.61
7.1.170.0140.00015.77
7.1.160.0000.01415.95
7.1.150.0060.00615.91
7.1.140.0030.00615.62
7.1.130.0060.00615.79
7.1.120.0030.01015.62
7.1.110.0090.00615.75
7.1.100.0140.00015.52
7.1.90.0100.00315.86
7.1.80.0040.00715.60
7.1.70.0050.00616.48
7.1.60.0090.00917.45
7.1.50.0040.01316.34
7.1.40.0030.00915.90
7.1.30.0030.00715.71
7.1.20.0060.00315.84
7.1.10.0090.00615.82
7.1.00.0080.03319.06
7.0.330.0060.00915.15
7.0.320.0000.01415.39
7.0.310.0040.01115.25
7.0.300.0070.00415.31
7.0.290.0060.00315.30
7.0.280.0000.01315.42
7.0.270.0070.00715.43
7.0.260.0000.01115.12
7.0.250.0110.00415.21
7.0.240.0110.00015.18
7.0.230.0040.01115.50
7.0.220.0000.01115.47
7.0.210.0040.01115.35
7.0.200.0010.00915.83
7.0.190.0100.00615.43
7.0.180.0030.01015.44
7.0.170.0030.01015.45
7.0.160.0030.00715.41
7.0.150.0030.01215.44
7.0.140.0060.03818.68
7.0.130.0040.00715.41
7.0.120.0070.02318.58
7.0.110.0060.00615.45
7.0.100.0060.00615.23
7.0.90.0070.00415.24
7.0.80.0030.01015.17
7.0.70.0030.00615.40
7.0.60.3510.02517.54
7.0.50.0120.02818.03
7.0.40.5800.02816.97
7.0.30.4050.03516.88
7.0.20.5750.04616.84
7.0.10.3800.04016.99
7.0.00.4550.03216.77
5.6.400.0080.00414.24
5.6.390.0070.01114.57
5.6.380.0030.01014.68
5.6.370.0030.00614.25
5.6.360.0130.00314.24
5.6.350.0030.01014.55
5.6.340.0040.00714.68
5.6.330.0060.00614.22
5.6.320.0070.00314.64
5.6.310.0070.01014.30
5.6.300.0150.00014.62
5.6.290.0100.00314.66
5.6.280.0030.04017.80
5.6.270.0000.01714.72
5.6.260.0000.01414.31
5.6.250.0000.00914.17
5.6.240.0030.00614.72
5.6.230.0000.01414.66
5.6.220.0000.01014.60
5.6.210.0080.03217.61
5.6.200.0080.04817.68
5.6.190.0080.04117.75
5.6.180.0060.03617.56
5.6.170.0120.04017.72
5.6.160.0100.04317.60
5.6.150.0100.03817.85
5.6.140.0070.04717.61
5.6.130.0050.05117.56
5.6.120.0100.03517.76
5.6.110.0050.04317.75
5.6.100.0080.03517.49
5.6.90.0080.03717.76
5.6.80.0080.04617.30
5.6.70.0100.05117.41
5.6.60.0100.00014.14
5.6.50.0040.00814.37
5.6.40.0030.01414.20
5.6.30.0030.01014.39
5.6.20.0000.01014.26
5.6.10.0090.00314.61
5.6.00.0000.01014.43
5.5.380.0030.00714.15
5.5.370.0040.01214.33
5.5.360.0060.00614.51
5.5.350.0110.02917.36
5.5.340.0040.03417.61
5.5.330.0100.03017.45
5.5.320.0080.03417.69
5.5.310.0080.03317.59
5.5.300.0140.02717.55
5.5.290.0040.04417.55
5.5.280.0150.03017.62
5.5.270.0100.04417.62
5.5.260.0120.02917.48
5.5.250.0030.03617.46
5.5.240.0080.04417.45
5.5.230.0060.00914.18
5.5.220.0120.00614.28
5.5.210.0040.00414.25
5.5.200.0080.00314.15
5.5.190.0060.00614.47
5.5.180.0090.00614.30
5.5.170.0040.01114.47
5.5.160.0110.00314.07
5.5.150.0090.00314.22
5.5.140.0060.00614.10
5.5.130.0070.00714.01
5.5.120.0060.00914.11
5.5.110.0000.00914.26
5.5.100.0040.01114.30
5.5.90.0030.00914.28
5.5.80.0090.00614.05
5.5.70.0120.00313.81
5.5.60.0120.00014.37
5.5.50.0030.00614.26
5.5.40.0030.01014.18
5.5.30.0030.00814.12
5.5.20.0040.00814.39
5.5.10.0090.00614.17
5.5.00.0080.00813.85
5.4.450.0040.03415.25
5.4.440.0140.03615.21
5.4.430.0080.04015.12
5.4.420.0100.03315.17
5.4.410.0050.03215.13
5.4.400.0100.03715.10
5.4.390.0050.03614.96
5.4.380.0030.03515.03
5.4.370.0050.03414.99
5.4.360.0070.03014.98
5.4.350.0100.02815.00
5.4.340.0120.04015.06
5.4.330.0060.00610.86
5.4.320.0070.04715.09
5.4.310.0050.03015.01
5.4.300.0130.03215.02
5.4.290.0080.04214.99
5.4.280.0030.03714.90
5.4.270.0100.02815.10
5.4.260.0070.02714.94
5.4.250.0090.03015.02
5.4.240.0050.04015.07
5.4.230.0110.02815.03
5.4.220.0120.02514.95
5.4.210.0190.02915.09
5.4.200.0100.02915.02
5.4.190.0080.03315.04
5.4.180.0080.02815.15
5.4.170.0180.02314.93
5.4.160.0100.02614.97
5.4.150.0070.03014.97
5.4.140.0090.02313.74
5.4.130.0080.02513.54
5.4.120.0050.03013.73
5.4.110.0030.03213.74
5.4.100.0080.02713.69
5.4.90.0070.02613.50
5.4.80.0030.03013.67
5.4.70.0080.02813.71
5.4.60.0070.03513.68
5.4.50.0040.03013.62
5.4.40.0050.02813.77
5.4.30.0080.02413.66
5.4.20.0050.02913.62
5.4.10.0140.02313.67
5.4.00.0070.02713.46
5.3.290.0150.03712.72
5.3.280.0100.02812.74
5.3.270.0110.03312.64
5.3.260.0030.04012.74
5.3.250.0050.03512.66
5.3.240.0080.02612.75
5.3.230.0100.02612.69
5.3.220.0050.03912.66
5.3.210.0090.02912.73
5.3.200.0050.02712.65
5.3.190.0120.02312.74
5.3.180.0070.03312.70
5.3.170.0110.03312.73
5.3.160.0080.02612.67
5.3.150.0050.03012.67
5.3.140.0060.02912.72
5.3.130.0070.02912.71
5.3.120.0050.03012.68
5.3.110.0050.02712.72
5.3.100.0100.02512.43
5.3.90.0120.02212.39
5.3.80.0130.02312.45
5.3.70.0170.02312.38
5.3.60.0070.02512.33
5.3.50.0060.02812.35
5.3.40.0060.02612.30
5.3.30.0060.02712.40
5.3.20.0070.02712.25
5.3.10.0080.03812.16
5.3.00.0090.02712.22
5.2.170.0070.05311.05
5.2.160.0170.04011.05
5.2.150.0100.04011.11
5.2.140.0130.03711.05
5.2.130.0100.03710.91
5.2.120.0070.03711.05
5.2.110.0030.04311.05
5.2.100.0030.04311.06
5.2.90.0100.03710.91
5.2.80.0000.04711.05
5.2.70.0070.04311.21
5.2.60.0130.05011.07
5.2.50.0200.04310.98
5.2.40.0130.03711.12
5.2.30.0070.06010.90
5.2.20.0070.04011.00
5.2.10.0000.04310.77
5.2.00.0100.04010.74
5.1.60.0100.0309.93
5.1.50.0000.0409.95
5.1.40.0070.04710.09
5.1.30.0100.04710.36
5.1.20.0070.04310.33
5.1.10.0100.03010.05
5.1.00.0100.0479.99
5.0.50.0000.0208.64
5.0.40.0000.0208.28
5.0.30.0000.0308.15
5.0.20.0000.0208.37
5.0.10.0000.0208.20
5.0.00.0000.0308.19
4.4.90.0030.0137.59
4.4.80.0000.0177.59
4.4.70.0000.0177.59
4.4.60.0000.0177.59
4.4.50.0030.0137.59
4.4.40.0070.0207.59
4.4.30.0030.0177.59
4.4.20.0070.0107.59
4.4.10.0030.0137.59
4.4.00.0000.0237.59
4.3.110.0030.0137.59
4.3.100.0000.0177.59
4.3.90.0000.0137.59
4.3.80.0000.0277.59
4.3.70.0000.0277.59
4.3.60.0000.0177.59
4.3.50.0000.0137.59
4.3.40.0000.0237.59
4.3.30.0000.0137.59
4.3.20.0000.0177.59
4.3.10.0000.0177.59
4.3.00.0030.0137.59

preferences:
42.53 ms | 400 KiB | 5 Q