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"; $docs = array(); $iterations = 100000; //100000; echo "Count of DOMDocuments: {$iterations}" . PHP_EOL. PHP_EOL; 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(true); foreach ($docs as $d) { $sos->contains($d); } $finis = microtime(true); $time_to_check = $finis - $start; $mem_spl = memory_get_usage(); $mem_used = $mem_spl - $mem_empty; printf("SplObjectStorage:\nTime to fill: %0.12f. [s]\nTime to check: %0.12f. [s]\nMemory: %d [MB]\n\n", $time_to_fill, $time_to_check, $mem_used/1024/1024); unset($sos); $mem_empty = memory_get_usage(); // Test arrays: $start = microtime(TRUE); $arr = new SplFixedArray($iterations); // Load the array $_i = 0; foreach ($docs as $d) { $arr[$_i] = $d; $_i++; } $finis = microtime(TRUE); $time_to_fill = $finis - $start; // Check membership on the array $start = microtime(FALSE); $_i = 0; foreach ($docs as $d) { isset($arr[$_i]); $_i++; } $finis = microtime(FALSE); $time_to_check = $finis - $start; $mem_arr = memory_get_usage(); $mem_used = $mem_arr - $mem_empty; printf("SplFixedArray:\nTime to fill: %0.12f. [s]\nTime to check: %0.12f. [s]\nMemory: %d [MB]\n\n", $time_to_fill, $time_to_check, $mem_used/1024/1024); $mem_empty = memory_get_usage(); // Test arrays: $start = microtime(TRUE); $arr = array(); $_i =0; // Load the array foreach ($docs as $d) { $arr[$_i] = $d; $_i++; } $finis = microtime(TRUE); $time_to_fill = $finis - $start; // Check membership on the array $start = microtime(FALSE); $_i =0; foreach ($docs as $d) { isset($arr[$_i]); $_i++; } $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. [s]\nTime to check: %0.12f. [s]\nMemory: %d [MB]\n\n", $time_to_fill, $time_to_check, $mem_used/1024/1024); ?>

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.3.120.0500.19060.93
7.3.110.0240.15561.03
7.3.100.0400.08460.94
7.3.90.0400.11460.87
7.3.80.0260.11560.74
7.3.70.0300.15561.01
7.3.60.0330.09760.98
7.3.50.0200.11561.03
7.3.40.0300.12261.07
7.3.30.0330.09760.88
7.3.20.0540.07464.46
7.3.10.0300.10864.27
7.3.00.0330.09064.18
7.2.240.0470.24061.13
7.2.230.0300.16760.70
7.2.220.0300.19561.05
7.2.210.0360.19860.84
7.2.200.0330.19260.88
7.2.190.0330.15360.79
7.2.180.0390.17160.88
7.2.170.0470.16060.85
7.2.160.0430.16461.05
7.2.150.0430.14664.40
7.2.140.0230.17464.38
7.2.130.0230.19364.70
7.2.120.0330.17064.63
7.2.110.0300.18964.46
7.2.100.0400.25064.61
7.2.90.0430.23464.38
7.2.80.0440.15164.57
7.2.70.0360.17664.44
7.2.60.0430.15264.34
7.2.50.0400.17264.42
7.2.40.0430.16264.65
7.2.30.0360.18164.69
7.2.20.0430.14664.50
7.2.10.0330.16364.64
7.2.00.0210.15365.86
7.1.330.0490.22763.39
7.1.320.0360.21763.38
7.1.310.0390.20063.20
7.1.300.0330.18763.33
7.1.290.0460.18963.63
7.1.280.0200.20563.46
7.1.270.0200.20063.60
7.1.260.0270.19663.43
7.1.250.0200.25263.49
7.1.70.0100.14064.85
7.1.60.0300.19064.76
7.1.50.0330.15864.48
7.1.00.0100.25069.84
7.0.200.9950.17664.35
7.0.140.0170.23072.67
7.0.80.5400.18369.58
7.0.70.5900.16769.52
7.0.60.8070.16769.48
7.0.50.8130.23069.87
7.0.40.2630.22751.17
7.0.30.3370.22351.20
7.0.20.4070.23051.14
7.0.10.3400.26051.23
7.0.00.2830.18351.16
5.6.280.0300.52099.70
5.6.230.0300.46098.27
5.6.220.0430.53098.16
5.6.210.0430.56098.42
5.6.200.0500.57398.68
5.6.190.0170.47098.28
5.6.180.0430.52398.75
5.6.170.0400.57098.71
5.6.160.0370.53098.64
5.6.150.0270.51798.36
5.6.140.0430.52398.78
5.6.130.0200.53798.36
5.6.120.0330.51798.77
5.6.110.0500.59098.84
5.6.100.0270.45398.38
5.6.90.0330.50098.70
5.6.80.0300.53798.07
5.6.70.0470.257103.04
5.6.60.0400.233103.04
5.6.50.0300.210103.14
5.6.40.0600.260103.05
5.6.30.0370.277103.13
5.6.20.0270.280103.07
5.6.10.0370.247103.05
5.6.00.0200.263102.95
5.5.370.0300.49098.09
5.5.360.0230.45098.08
5.5.350.0370.59398.13
5.5.340.0170.54098.57
5.5.330.0730.42098.45
5.5.320.0230.57798.51
5.5.310.0330.59798.57
5.5.300.0300.54798.55
5.5.290.0400.51398.55
5.5.280.0330.54098.45
5.5.270.0500.55098.53
5.5.260.0230.57398.58
5.5.250.0270.52798.37
5.5.240.0370.53097.98
5.5.230.0300.280102.96
5.5.220.0400.237102.91
5.5.210.0500.253102.86
5.5.200.0270.260102.80
5.5.190.0300.267102.64
5.5.180.0200.267102.89
5.5.160.0400.253102.92
5.5.150.0300.257102.73
5.5.140.0500.243102.83
5.5.130.0430.273102.87
5.5.120.0430.207102.64
5.5.110.0370.207102.79
5.5.100.0270.217102.70
5.5.90.0170.280102.66
5.5.80.0230.253102.71
5.5.70.0400.247102.80
5.5.60.0470.237102.58
5.5.50.0200.287102.71
5.5.40.0130.217102.58
5.5.30.0470.220102.79
5.5.20.0200.257102.73
5.5.10.0330.253102.70
5.5.00.0400.203102.68
5.4.450.0230.273101.96
5.4.440.0500.223101.83
5.4.430.0270.223101.90
5.4.420.0270.243101.86
5.4.410.0330.247101.81
5.4.400.0400.247101.55
5.4.390.0300.247101.63
5.4.380.0300.283101.58
5.4.370.0200.213101.41
5.4.360.0270.267101.64
5.4.350.0400.223101.48
5.4.340.0430.250101.73
5.4.320.0370.207101.48
5.4.310.0500.223101.63
5.4.300.0400.260101.54
5.4.290.0330.197101.59
5.4.280.0230.197101.58
5.4.270.0430.260101.55
5.4.260.0270.193101.41
5.4.250.0530.253101.51
5.4.240.0570.230101.57
5.4.230.0430.220101.47
5.4.220.0430.243101.53
5.4.210.0400.197101.61
5.4.200.0400.240101.38
5.4.190.0270.277101.52
5.4.180.0400.227101.62
5.4.170.0370.203101.53
5.4.160.0530.167101.49
5.4.150.0330.257101.53
5.4.140.0230.20099.02
5.4.130.0300.22798.91
5.4.120.0230.24798.91
5.4.110.0230.20099.03
5.4.100.0370.18098.91
5.4.90.0530.16098.79
5.4.80.0400.17798.84
5.4.70.0200.19798.95
5.4.60.0270.20398.84
5.4.50.0270.20398.82
5.4.40.0130.21798.83
5.4.30.0230.16798.91
5.4.20.0330.15798.95
5.4.10.0370.19398.99
5.4.00.0370.18398.35
5.3.290.0230.14797.50
5.3.280.0300.13097.29
5.3.270.0330.18397.45
5.3.260.0170.19797.41
5.3.250.0370.18097.25
5.3.240.0370.16097.36
5.3.230.0200.17397.35
5.3.220.0300.17097.27
5.3.210.0170.14797.38
5.3.200.0370.11797.43
5.3.190.0230.13097.29
5.3.180.0270.12797.42
5.3.170.0270.13097.40
5.3.160.0370.13397.27
5.3.150.0370.13097.22
5.3.140.0230.22097.28
5.3.130.0270.13797.41
5.3.120.0300.11797.41
5.3.110.0500.18797.41
5.3.100.0300.12396.89
5.3.90.0270.12796.69
5.3.80.0170.12796.71
5.3.70.0400.11096.64
5.3.60.0400.10796.75
5.3.50.0170.12796.75
5.3.40.0400.19796.70
5.3.30.0200.22396.76
5.3.20.0230.22396.54
5.3.10.0230.23096.57
5.3.00.0300.29096.61
5.2.170.0170.24791.19
5.2.160.0300.24391.27
5.2.150.0070.18091.11
5.2.140.0330.23091.32
5.2.130.0300.22091.29
5.2.120.0300.24091.22
5.2.110.0200.22791.07
5.2.100.0400.19791.12
5.2.90.0430.18091.18
5.2.80.0330.21791.27
5.2.70.0270.22791.31
5.2.60.0470.22391.30
5.2.50.0270.23791.15
5.2.40.0770.23091.09
5.2.30.0430.25091.13
5.2.20.0300.21091.23
5.2.10.0370.19091.19
5.2.00.0300.15080.05
5.1.60.0330.19394.80
5.1.50.0330.20394.77
5.1.40.0200.20094.77
5.1.30.0330.19794.98
5.1.20.0400.20095.03
5.1.10.0400.14094.81
5.1.00.0270.17794.84
5.0.50.0000.03711.64
5.0.40.0070.03311.64
5.0.30.0100.06311.64
5.0.20.0030.03711.64
5.0.10.0000.03711.64
5.0.00.0000.07011.64
4.4.90.0030.03711.64
4.4.80.0000.03711.64
4.4.70.0070.03011.64
4.4.60.0000.03311.64
4.4.50.0000.03711.64
4.4.40.0000.03711.64
4.4.30.0000.02311.64
4.4.20.0100.02711.64
4.4.10.0070.02011.64
4.4.00.0000.05711.64
4.3.110.0030.03311.64
4.3.100.0070.02711.64
4.3.90.0030.03311.64
4.3.80.0000.04011.64
4.3.70.0000.04011.64
4.3.60.0070.03011.64
4.3.50.0030.03311.64
4.3.40.0030.05011.64
4.3.30.0000.03011.64
4.3.20.0030.02711.64
4.3.10.0000.02711.64
4.3.00.0000.03011.64

preferences:
39.47 ms | 401 KiB | 5 Q