3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string1 = 'The lazy cat jumps over the fast fox'; $string2 = 'The fast fox jumps over the lazy cat'; $len=strlen($string1); const runs=31337; $start=microtime(1); $i=0;while (++$i<runs) { $xor = $string1 ^ $string2; $pos=0; while(($pos+=strspn($xor,"\0",$pos))<$len) $pos++; } print "ircmax's XOR+strspn + ka's loop:<br>\n".(microtime(1)-$start)."sec<br>\n<br>\n"; $start=microtime(1); $i=0;while (++$i<runs) { for ($offset = 0; $offset < $len; ++$offset) { if ($string1[$offset] !== $string2[$offset]) {} } } print "NikiC's example from question body:<br>\n".(microtime(1)-$start)."sec<br>\n";

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.0160.07215.06
7.4.00.0100.07614.99
7.3.130.0070.11214.84
7.3.120.0100.08514.79
7.3.110.0070.07614.79
7.3.100.0030.07615.02
7.3.90.0070.07914.87
7.3.80.0030.07514.74
7.3.70.0030.08214.93
7.3.60.0000.07514.70
7.3.50.0070.06914.87
7.3.40.0130.07814.78
7.3.30.0030.08814.76
7.3.20.0070.07116.58
7.3.10.0000.08116.48
7.3.00.0030.07316.69
7.2.260.0100.12215.02
7.2.250.0100.11714.95
7.2.240.0030.08415.28
7.2.230.0030.08915.00
7.2.220.0030.07715.20
7.2.210.0100.07214.90
7.2.200.0030.08214.86
7.2.190.0100.07314.96
7.2.180.0100.08315.04
7.2.170.0100.07415.05
7.2.160.0000.08214.75
7.2.150.0000.09216.98
7.2.140.0070.08716.77
7.2.130.0100.07516.88
7.2.120.0070.07617.01
7.2.110.0000.12516.63
7.2.100.0070.07416.97
7.2.90.0070.07716.68
7.2.80.0070.07716.75
7.2.70.0000.08816.73
7.2.60.0070.08416.83
7.2.50.0070.07316.98
7.2.40.0070.07417.05
7.2.30.0030.09016.86
7.2.20.0030.07416.95
7.2.10.0070.07916.91
7.2.00.0070.06818.08
7.1.330.0070.22115.57
7.1.320.0070.18915.88
7.1.310.0030.19215.65
7.1.300.0070.19315.69
7.1.290.0000.20015.49
7.1.280.0100.20315.55
7.1.270.0070.19215.69
7.1.260.0030.19215.71
7.1.250.0030.23915.80
7.1.240.0030.23315.82
7.1.230.0130.21315.77
7.1.220.0000.19815.82
7.1.210.0070.18315.56
7.1.200.0000.21415.64
7.1.190.0000.18415.88
7.1.180.0070.18615.89
7.1.170.0070.18515.71
7.1.160.0000.18215.92
7.1.150.0030.21015.66
7.1.140.0100.18215.59
7.1.130.0030.18715.71
7.1.120.0100.23715.99
7.1.110.0000.23915.74
7.1.100.0000.19715.78
7.1.90.0070.21615.89
7.1.80.0030.22215.85
7.1.70.0000.14616.43
7.1.60.0070.16217.73
7.1.50.0050.15916.41
7.1.40.0030.21116.00
7.1.30.0000.23615.88
7.1.20.0000.21015.82
7.1.10.0030.18815.85
7.1.00.0070.21318.95
7.0.330.0100.20015.44
7.0.320.0030.19215.27
7.0.310.0000.19815.38
7.0.300.0070.18815.28
7.0.290.0000.19115.25
7.0.280.0070.23015.31
7.0.270.0000.22415.36
7.0.260.0030.19515.46
7.0.250.0070.19015.54
7.0.240.0000.18515.39
7.0.230.0070.20215.53
7.0.220.0070.22915.48
7.0.210.0030.20315.57
7.0.200.0030.15916.11
7.0.190.0030.23915.48
7.0.180.0030.23615.50
7.0.170.0030.18815.46
7.0.160.0000.18815.48
7.0.150.0070.22615.18
7.0.140.0000.20318.61
7.0.130.0000.20015.35
7.0.120.0030.19515.50
7.0.110.0000.18615.27
7.0.100.0030.25015.09
7.0.90.0100.21015.27
7.0.80.0000.27315.38
7.0.70.0100.16517.60
7.0.60.0050.17217.76
7.0.50.0080.22517.95
7.0.40.0080.18816.79
7.0.30.0050.18216.70
7.0.20.0050.18616.72
7.0.10.0080.21416.75
7.0.00.0150.19016.70
5.6.400.0030.37314.57
5.6.390.0070.40914.29
5.6.380.0070.35213.91
5.6.370.0070.36214.50
5.6.360.0130.38714.68
5.6.350.0030.39814.70
5.6.340.0070.38814.35
5.6.330.0030.38814.24
5.6.320.0070.37814.02
5.6.310.0100.39714.48
5.6.300.0030.40414.73
5.6.290.0030.38314.29
5.6.280.0030.33917.66
5.6.270.0030.39914.30
5.6.260.0030.39114.40
5.6.250.0030.46614.39
5.6.240.0000.37814.12
5.6.230.0000.36514.42
5.6.220.0030.29317.42
5.6.210.0080.33417.43
5.6.200.0050.30717.78
5.6.190.0080.36017.63
5.6.180.0100.33917.65
5.6.170.0080.31117.80
5.6.160.0050.30617.59
5.6.150.0030.38417.64
5.6.140.0030.34117.65
5.6.130.0050.33917.63
5.6.120.0120.33617.59
5.6.110.0100.32417.59
5.6.100.0070.35217.62
5.6.90.0030.32417.67
5.6.80.0050.31017.39
5.6.70.0070.32917.40
5.6.60.0050.35417.26
5.6.50.0050.30917.37
5.6.40.0130.35717.49
5.6.30.0070.31817.27
5.6.20.0080.34417.25
5.6.10.0030.31517.16
5.6.00.0080.35117.49
5.5.380.0030.40014.04
5.5.370.0030.43914.42
5.5.360.0100.32217.43
5.5.350.0030.38717.52
5.5.340.0080.34617.64
5.5.330.0100.30617.78
5.5.320.0120.34217.47
5.5.310.0050.35617.67
5.5.300.0100.32217.53
5.5.290.0080.32917.71
5.5.280.0070.30717.54
5.5.270.0050.36317.53
5.5.260.0050.37717.53
5.5.250.0080.34417.44
5.5.240.0070.33817.34
5.5.230.0030.35817.04
5.5.220.0050.35017.06
5.5.210.0070.33517.27
5.5.200.0030.34917.19
5.5.190.0070.34717.19
5.5.180.0000.37017.19
5.5.170.0070.42814.09
5.5.160.0100.32117.25
5.5.150.0100.34317.35
5.5.140.0050.34417.19
5.5.130.0050.34017.11
5.5.120.0080.32817.13
5.5.110.0080.34517.20
5.5.100.0020.34316.88
5.5.90.0050.32417.16
5.5.80.0050.29917.15
5.5.70.0050.33217.11
5.5.60.0030.35917.30
5.5.50.0050.28517.06
5.5.40.0180.31317.12
5.5.30.0080.33317.10
5.5.20.0030.29217.20
5.5.10.0100.28117.33
5.5.00.0020.34117.19
5.4.450.0030.32115.17
5.4.440.0070.33815.25
5.4.430.0050.34215.10
5.4.420.0020.37215.30
5.4.410.0070.32715.11
5.4.400.0070.32415.12
5.4.390.0100.37014.89
5.4.380.0080.34315.18
5.4.370.0080.32815.04
5.4.360.0080.32314.98
5.4.350.0030.32315.05
5.4.340.0100.33415.06
5.4.330.0030.41810.89
5.4.320.0050.38015.16
5.4.310.0050.32715.10
5.4.300.0070.34315.05
5.4.290.0030.33015.18
5.4.280.0030.33615.20
5.4.270.0020.35715.11
5.4.260.0070.33815.01
5.4.250.0100.30115.07
5.4.240.0130.34915.07
5.4.230.0050.34415.04
5.4.220.0030.32214.97
5.4.210.0030.32615.11
5.4.200.0050.33614.98
5.4.190.0130.31115.05
5.4.180.0070.34314.91
5.4.170.0030.33714.99
5.4.160.0080.36715.04
5.4.150.0070.36414.92
5.4.140.0120.31813.60
5.4.130.0000.34113.62
5.4.120.0050.31613.50
5.4.110.0070.30313.54
5.4.100.0050.32513.67
5.4.90.0080.34013.65
5.4.80.0080.35813.76
5.4.70.0050.30613.78
5.4.60.0080.32913.53
5.4.50.0080.36513.60
5.4.40.0030.32213.68
5.4.30.0050.34113.71
5.4.20.0080.35113.65
5.4.10.0080.32913.71
5.4.00.0080.36213.33
5.3.290.0020.36112.66
5.3.280.0050.41312.55
5.3.270.0080.44112.61
5.3.260.0050.37212.62
5.3.250.0100.41012.55
5.3.240.0070.39512.60
5.3.230.0070.40512.59
5.3.220.0120.41712.59
5.3.210.0050.40612.60
5.3.200.0070.40412.51
5.3.190.0030.37412.57
5.3.180.0030.41812.56
5.3.170.0070.40012.60
5.3.160.0080.42312.59
5.3.150.0070.38512.52
5.3.140.0070.41112.53
5.3.130.0070.40912.58
5.3.120.0100.37412.52
5.3.110.0080.42012.58
5.3.100.0100.39212.26
5.3.90.0030.40812.33
5.3.80.0070.41312.21
5.3.70.0050.41712.33
5.3.60.0070.37712.25
5.3.50.0050.42612.22
5.3.40.0070.39312.25
5.3.30.0070.42412.25
5.3.20.0130.35512.16
5.3.10.0030.36112.15
5.3.00.0080.37412.12
5.2.170.0030.06312.31
5.2.160.0000.06712.31
5.2.150.0030.04712.31
5.2.140.0000.03712.31
5.2.130.0100.02712.31
5.2.120.0030.03012.31
5.2.110.0100.05712.31
5.2.100.0070.06012.31
5.2.90.0170.05012.31
5.2.80.0070.06312.31
5.2.70.0100.05012.31
5.2.60.0030.06012.31
5.2.50.0030.05712.31
5.2.40.0130.04312.31
5.2.30.0030.05312.31
5.2.20.0030.04312.31
5.2.10.0130.05712.31
5.2.00.0070.05012.31
5.1.60.0070.04712.31
5.1.50.0130.05012.31
5.1.40.0000.05312.31
5.1.30.0070.05012.31
5.1.20.0030.04012.31
5.1.10.0070.02312.31
5.1.00.0000.04012.31
5.0.50.0000.02312.31
5.0.40.0030.02712.31
5.0.30.0030.03012.31
5.0.20.0000.02012.31
5.0.10.0070.01312.31
5.0.00.0030.03012.31
4.4.90.0070.03312.31
4.4.80.0000.03712.31
4.4.70.0030.03012.31
4.4.60.0070.02312.31
4.4.50.0000.03312.31
4.4.40.0070.05012.31
4.4.30.0000.02312.31
4.4.20.0000.01712.31
4.4.10.0000.02012.31
4.4.00.0000.03312.31
4.3.110.0030.02712.31
4.3.100.0000.01712.31
4.3.90.0000.01712.31
4.3.80.0000.02312.31
4.3.70.0000.01712.31
4.3.60.0000.01712.31
4.3.50.0000.02312.31
4.3.40.0030.02312.31
4.3.30.0030.01312.31
4.3.20.0000.01712.31
4.3.10.0000.01712.31
4.3.00.0030.01712.31

preferences:
34.75 ms | 401 KiB | 5 Q