3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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) { // print 'Diff @'.$pos.' String1:'.$string1[$pos].' String2:'.$string2[$pos]." <br>\n"; $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 'Diff @'.$offset.' String1:'.$string1[$offset].' String2:'.$string2[$offset]." <br>\n"; } } } print "NikiC's example from question body:<br>\n".(microtime(1)-$start)."sec<br>\n";
Output for 7.1.0
ircmax's XOR+strspn + ka's loop:<br> 0.052539110183716sec<br> <br> NikiC's example from question body:<br> 0.077126026153564sec<br>
Output for 7.0.14
ircmax's XOR+strspn + ka's loop:<br> 0.058712005615234sec<br> <br> NikiC's example from question body:<br> 0.077133893966675sec<br>
Output for 7.0.12
ircmax's XOR+strspn + ka's loop:<br> 0.058388948440552sec<br> <br> NikiC's example from question body:<br> 0.090054988861084sec<br>
Output for 7.0.6
ircmax's XOR+strspn + ka's loop:<br> 0.040426015853882sec<br> <br> NikiC's example from question body:<br> 0.053814888000488sec<br>
Output for 7.0.5
ircmax's XOR+strspn + ka's loop:<br> 0.052006959915161sec<br> <br> NikiC's example from question body:<br> 0.060150146484375sec<br>
Output for 7.0.4
ircmax's XOR+strspn + ka's loop:<br> 0.048166990280151sec<br> <br> NikiC's example from question body:<br> 0.054150819778442sec<br>
Output for 7.0.3
ircmax's XOR+strspn + ka's loop:<br> 0.046280145645142sec<br> <br> NikiC's example from question body:<br> 0.053835153579712sec<br>
Output for 7.0.2
ircmax's XOR+strspn + ka's loop:<br> 0.035946846008301sec<br> <br> NikiC's example from question body:<br> 0.048441171646118sec<br>
Output for 7.0.1
ircmax's XOR+strspn + ka's loop:<br> 0.03417706489563sec<br> <br> NikiC's example from question body:<br> 0.047526836395264sec<br>
Output for 7.0.0
ircmax's XOR+strspn + ka's loop:<br> 0.050729990005493sec<br> <br> NikiC's example from question body:<br> 0.054176092147827sec<br>
Output for 5.6.28
ircmax's XOR+strspn + ka's loop:<br> 0.096185922622681sec<br> <br> NikiC's example from question body:<br> 0.13266897201538sec<br>
Output for 5.6.21
ircmax's XOR+strspn + ka's loop:<br> 0.082289934158325sec<br> <br> NikiC's example from question body:<br> 0.098107099533081sec<br>
Output for 5.6.20
ircmax's XOR+strspn + ka's loop:<br> 0.07502007484436sec<br> <br> NikiC's example from question body:<br> 0.096434831619263sec<br>
Output for 5.6.19
ircmax's XOR+strspn + ka's loop:<br> 0.06601881980896sec<br> <br> NikiC's example from question body:<br> 0.099163055419922sec<br>
Output for 5.6.18
ircmax's XOR+strspn + ka's loop:<br> 0.060581207275391sec<br> <br> NikiC's example from question body:<br> 0.096916913986206sec<br>
Output for 5.6.17
ircmax's XOR+strspn + ka's loop:<br> 0.085432052612305sec<br> <br> NikiC's example from question body:<br> 0.10817289352417sec<br>
Output for 5.6.16
ircmax's XOR+strspn + ka's loop:<br> 0.07443904876709sec<br> <br> NikiC's example from question body:<br> 0.10301303863525sec<br>
Output for 5.6.15
ircmax's XOR+strspn + ka's loop:<br> 0.063058137893677sec<br> <br> NikiC's example from question body:<br> 0.095541000366211sec<br>
Output for 5.6.14
ircmax's XOR+strspn + ka's loop:<br> 0.087537050247192sec<br> <br> NikiC's example from question body:<br> 0.098993062973022sec<br>
Output for 5.6.13
ircmax's XOR+strspn + ka's loop:<br> 0.064136028289795sec<br> <br> NikiC's example from question body:<br> 0.097548961639404sec<br>
Output for 5.6.12
ircmax's XOR+strspn + ka's loop:<br> 0.090874910354614sec<br> <br> NikiC's example from question body:<br> 0.12855696678162sec<br>
Output for 5.6.11
ircmax's XOR+strspn + ka's loop:<br> 0.08004903793335sec<br> <br> NikiC's example from question body:<br> 0.097285032272339sec<br>
Output for 5.6.10
ircmax's XOR+strspn + ka's loop:<br> 0.071973085403442sec<br> <br> NikiC's example from question body:<br> 0.097726821899414sec<br>
Output for 5.6.9
ircmax's XOR+strspn + ka's loop:<br> 0.078854084014893sec<br> <br> NikiC's example from question body:<br> 0.097280979156494sec<br>
Output for 5.6.8
ircmax's XOR+strspn + ka's loop:<br> 0.078608989715576sec<br> <br> NikiC's example from question body:<br> 0.096626043319702sec<br>
Output for 5.5.35
ircmax's XOR+strspn + ka's loop:<br> 0.082514047622681sec<br> <br> NikiC's example from question body:<br> 0.098975896835327sec<br>
Output for 5.5.34
ircmax's XOR+strspn + ka's loop:<br> 0.073383092880249sec<br> <br> NikiC's example from question body:<br> 0.10378193855286sec<br>
Output for 5.5.33
ircmax's XOR+strspn + ka's loop:<br> 0.066828012466431sec<br> <br> NikiC's example from question body:<br> 0.099158048629761sec<br>
Output for 5.5.32
ircmax's XOR+strspn + ka's loop:<br> 0.06489086151123sec<br> <br> NikiC's example from question body:<br> 0.096410989761353sec<br>
Output for 5.5.31
ircmax's XOR+strspn + ka's loop:<br> 0.082021951675415sec<br> <br> NikiC's example from question body:<br> 0.098493814468384sec<br>
Output for 5.5.30
ircmax's XOR+strspn + ka's loop:<br> 0.079317092895508sec<br> <br> NikiC's example from question body:<br> 0.10133004188538sec<br>
Output for 5.5.29
ircmax's XOR+strspn + ka's loop:<br> 0.068475008010864sec<br> <br> NikiC's example from question body:<br> 0.10190796852112sec<br>
Output for 5.5.28
ircmax's XOR+strspn + ka's loop:<br> 0.090195894241333sec<br> <br> NikiC's example from question body:<br> 0.09791898727417sec<br>
Output for 5.5.27
ircmax's XOR+strspn + ka's loop:<br> 0.067603826522827sec<br> <br> NikiC's example from question body:<br> 0.098493099212646sec<br>
Output for 5.5.26
ircmax's XOR+strspn + ka's loop:<br> 0.079850912094116sec<br> <br> NikiC's example from question body:<br> 0.10146999359131sec<br>
Output for 5.5.25
ircmax's XOR+strspn + ka's loop:<br> 0.085722923278809sec<br> <br> NikiC's example from question body:<br> 0.098704099655151sec<br>
Output for 5.5.24
ircmax's XOR+strspn + ka's loop:<br> 0.05814790725708sec<br> <br> NikiC's example from question body:<br> 0.0835280418396sec<br>
Output for 5.4.45
ircmax's XOR+strspn + ka's loop:<br> 0.064060211181641sec<br> <br> NikiC's example from question body:<br> 0.097908020019531sec<br>
Output for 5.4.44
ircmax's XOR+strspn + ka's loop:<br> 0.062018871307373sec<br> <br> NikiC's example from question body:<br> 0.1012179851532sec<br>
Output for 5.4.43
ircmax's XOR+strspn + ka's loop:<br> 0.083210229873657sec<br> <br> NikiC's example from question body:<br> 0.10116505622864sec<br>
Output for 5.4.42
ircmax's XOR+strspn + ka's loop:<br> 0.075006008148193sec<br> <br> NikiC's example from question body:<br> 0.09885311126709sec<br>
Output for 5.4.41
ircmax's XOR+strspn + ka's loop:<br> 0.085340023040771sec<br> <br> NikiC's example from question body:<br> 0.10739493370056sec<br>
Output for 5.4.40
ircmax's XOR+strspn + ka's loop:<br> 0.086422920227051sec<br> <br> NikiC's example from question body:<br> 0.10220408439636sec<br>
Output for 5.4.39
ircmax's XOR+strspn + ka's loop:<br> 0.084233999252319sec<br> <br> NikiC's example from question body:<br> 0.10056018829346sec<br>
Output for 5.4.38
ircmax's XOR+strspn + ka's loop:<br> 0.062892198562622sec<br> <br> NikiC's example from question body:<br> 0.10195183753967sec<br>
Output for 5.4.37
ircmax's XOR+strspn + ka's loop:<br> 0.080512046813965sec<br> <br> NikiC's example from question body:<br> 0.10206913948059sec<br>
Output for 5.4.36
ircmax's XOR+strspn + ka's loop:<br> 0.084954977035522sec<br> <br> NikiC's example from question body:<br> 0.10132384300232sec<br>
Output for 5.4.35
ircmax's XOR+strspn + ka's loop:<br> 0.084341049194336sec<br> <br> NikiC's example from question body:<br> 0.10268592834473sec<br>
Output for 5.4.34
ircmax's XOR+strspn + ka's loop:<br> 0.075654983520508sec<br> <br> NikiC's example from question body:<br> 0.098666906356812sec<br>
Output for 5.4.32
ircmax's XOR+strspn + ka's loop:<br> 0.063288927078247sec<br> <br> NikiC's example from question body:<br> 0.096575021743774sec<br>
Output for 5.4.31
ircmax's XOR+strspn + ka's loop:<br> 0.085155010223389sec<br> <br> NikiC's example from question body:<br> 0.099884986877441sec<br>
Output for 5.4.30
ircmax's XOR+strspn + ka's loop:<br> 0.086854934692383sec<br> <br> NikiC's example from question body:<br> 0.10344696044922sec<br>
Output for 5.4.29
ircmax's XOR+strspn + ka's loop:<br> 0.093541145324707sec<br> <br> NikiC's example from question body:<br> 0.13856506347656sec<br>
Output for 5.4.28
ircmax's XOR+strspn + ka's loop:<br> 0.06586217880249sec<br> <br> NikiC's example from question body:<br> 0.10253500938416sec<br>
Output for 5.4.27
ircmax's XOR+strspn + ka's loop:<br> 0.082462072372437sec<br> <br> NikiC's example from question body:<br> 0.11219882965088sec<br>
Output for 5.4.26
ircmax's XOR+strspn + ka's loop:<br> 0.07033896446228sec<br> <br> NikiC's example from question body:<br> 0.10516095161438sec<br>
Output for 5.4.25
ircmax's XOR+strspn + ka's loop:<br> 0.07237696647644sec<br> <br> NikiC's example from question body:<br> 0.11269998550415sec<br>
Output for 5.4.24
ircmax's XOR+strspn + ka's loop:<br> 0.077371835708618sec<br> <br> NikiC's example from question body:<br> 0.10000109672546sec<br>
Output for 5.4.23
ircmax's XOR+strspn + ka's loop:<br> 0.069049119949341sec<br> <br> NikiC's example from question body:<br> 0.099684953689575sec<br>
Output for 5.4.22
ircmax's XOR+strspn + ka's loop:<br> 0.10215997695923sec<br> <br> NikiC's example from question body:<br> 0.12537097930908sec<br>
Output for 5.4.21
ircmax's XOR+strspn + ka's loop:<br> 0.085501909255981sec<br> <br> NikiC's example from question body:<br> 0.10102891921997sec<br>
Output for 5.4.20
ircmax's XOR+strspn + ka's loop:<br> 0.080203056335449sec<br> <br> NikiC's example from question body:<br> 0.10193610191345sec<br>
Output for 5.4.19
ircmax's XOR+strspn + ka's loop:<br> 0.08096981048584sec<br> <br> NikiC's example from question body:<br> 0.12934184074402sec<br>
Output for 5.4.18
ircmax's XOR+strspn + ka's loop:<br> 0.077805995941162sec<br> <br> NikiC's example from question body:<br> 0.098451137542725sec<br>
Output for 5.4.17
ircmax's XOR+strspn + ka's loop:<br> 0.080549001693726sec<br> <br> NikiC's example from question body:<br> 0.11637711524963sec<br>
Output for 5.4.16
ircmax's XOR+strspn + ka's loop:<br> 0.070433139801025sec<br> <br> NikiC's example from question body:<br> 0.10914278030396sec<br>
Output for 5.4.15
ircmax's XOR+strspn + ka's loop:<br> 0.088013172149658sec<br> <br> NikiC's example from question body:<br> 0.10098814964294sec<br>
Output for 5.4.14
ircmax's XOR+strspn + ka's loop:<br> 0.084132194519043sec<br> <br> NikiC's example from question body:<br> 0.1061909198761sec<br>
Output for 5.4.13
ircmax's XOR+strspn + ka's loop:<br> 0.088103055953979sec<br> <br> NikiC's example from question body:<br> 0.10154604911804sec<br>
Output for 5.4.12
ircmax's XOR+strspn + ka's loop:<br> 0.083482027053833sec<br> <br> NikiC's example from question body:<br> 0.10525584220886sec<br>
Output for 5.4.11
ircmax's XOR+strspn + ka's loop:<br> 0.078027009963989sec<br> <br> NikiC's example from question body:<br> 0.10117316246033sec<br>
Output for 5.4.10
ircmax's XOR+strspn + ka's loop:<br> 0.080642938613892sec<br> <br> NikiC's example from question body:<br> 0.12927412986755sec<br>
Output for 5.4.9
ircmax's XOR+strspn + ka's loop:<br> 0.091122150421143sec<br> <br> NikiC's example from question body:<br> 0.10544395446777sec<br>
Output for 5.4.8
ircmax's XOR+strspn + ka's loop:<br> 0.064061880111694sec<br> <br> NikiC's example from question body:<br> 0.10402703285217sec<br>
Output for 5.4.7
ircmax's XOR+strspn + ka's loop:<br> 0.066209077835083sec<br> <br> NikiC's example from question body:<br> 0.1070339679718sec<br>
Output for 5.4.6
ircmax's XOR+strspn + ka's loop:<br> 0.087392091751099sec<br> <br> NikiC's example from question body:<br> 0.10130310058594sec<br>
Output for 5.4.5
ircmax's XOR+strspn + ka's loop:<br> 0.071285009384155sec<br> <br> NikiC's example from question body:<br> 0.10720014572144sec<br>
Output for 5.4.4
ircmax's XOR+strspn + ka's loop:<br> 0.090857028961182sec<br> <br> NikiC's example from question body:<br> 0.10290503501892sec<br>
Output for 5.4.3
ircmax's XOR+strspn + ka's loop:<br> 0.070156812667847sec<br> <br> NikiC's example from question body:<br> 0.10751104354858sec<br>
Output for 5.4.2
ircmax's XOR+strspn + ka's loop:<br> 0.084630966186523sec<br> <br> NikiC's example from question body:<br> 0.11275410652161sec<br>
Output for 5.4.1
ircmax's XOR+strspn + ka's loop:<br> 0.078630924224854sec<br> <br> NikiC's example from question body:<br> 0.10060691833496sec<br>
Output for 5.4.0
ircmax's XOR+strspn + ka's loop:<br> 0.079925060272217sec<br> <br> NikiC's example from question body:<br> 0.10357785224915sec<br>
Output for 5.3.29
ircmax's XOR+strspn + ka's loop:<br> 0.085746049880981sec<br> <br> NikiC's example from question body:<br> 0.17219114303589sec<br>
Output for 5.3.28
ircmax's XOR+strspn + ka's loop:<br> 0.10465598106384sec<br> <br> NikiC's example from question body:<br> 0.12461805343628sec<br>
Output for 5.3.27
ircmax's XOR+strspn + ka's loop:<br> 0.10590004920959sec<br> <br> NikiC's example from question body:<br> 0.1382200717926sec<br>
Output for 5.3.26
ircmax's XOR+strspn + ka's loop:<br> 0.10579395294189sec<br> <br> NikiC's example from question body:<br> 0.13124179840088sec<br>
Output for 5.3.25
ircmax's XOR+strspn + ka's loop:<br> 0.10346984863281sec<br> <br> NikiC's example from question body:<br> 0.12401294708252sec<br>
Output for 5.3.24
ircmax's XOR+strspn + ka's loop:<br> 0.080816984176636sec<br> <br> NikiC's example from question body:<br> 0.12352395057678sec<br>
Output for 5.3.23
ircmax's XOR+strspn + ka's loop:<br> 0.10281705856323sec<br> <br> NikiC's example from question body:<br> 0.1283700466156sec<br>
Output for 5.3.22
ircmax's XOR+strspn + ka's loop:<br> 0.082760095596313sec<br> <br> NikiC's example from question body:<br> 0.12878203392029sec<br>
Output for 5.3.21
ircmax's XOR+strspn + ka's loop:<br> 0.082011938095093sec<br> <br> NikiC's example from question body:<br> 0.12824296951294sec<br>
Output for 5.3.20
ircmax's XOR+strspn + ka's loop:<br> 0.1199631690979sec<br> <br> NikiC's example from question body:<br> 0.13302302360535sec<br>
Output for 5.3.19
ircmax's XOR+strspn + ka's loop:<br> 0.092330932617188sec<br> <br> NikiC's example from question body:<br> 0.14083695411682sec<br>
Output for 5.3.18
ircmax's XOR+strspn + ka's loop:<br> 0.10421514511108sec<br> <br> NikiC's example from question body:<br> 0.12800693511963sec<br>
Output for 5.3.17
ircmax's XOR+strspn + ka's loop:<br> 0.09286093711853sec<br> <br> NikiC's example from question body:<br> 0.12387490272522sec<br>
Output for 5.3.16
ircmax's XOR+strspn + ka's loop:<br> 0.10558009147644sec<br> <br> NikiC's example from question body:<br> 0.12825584411621sec<br>
Output for 5.3.15
ircmax's XOR+strspn + ka's loop:<br> 0.088451147079468sec<br> <br> NikiC's example from question body:<br> 0.12534999847412sec<br>
Output for 5.3.14
ircmax's XOR+strspn + ka's loop:<br> 0.090610980987549sec<br> <br> NikiC's example from question body:<br> 0.1404139995575sec<br>
Output for 5.3.13
ircmax's XOR+strspn + ka's loop:<br> 0.082270860671997sec<br> <br> NikiC's example from question body:<br> 0.16083097457886sec<br>
Output for 5.3.12
ircmax's XOR+strspn + ka's loop:<br> 0.088604927062988sec<br> <br> NikiC's example from question body:<br> 0.1326699256897sec<br>
Output for 5.3.11
ircmax's XOR+strspn + ka's loop:<br> 0.10487389564514sec<br> <br> NikiC's example from question body:<br> 0.12552213668823sec<br>
Output for 5.3.10
ircmax's XOR+strspn + ka's loop:<br> 0.10190606117249sec<br> <br> NikiC's example from question body:<br> 0.12938904762268sec<br>
Output for 5.3.9
ircmax's XOR+strspn + ka's loop:<br> 0.082277059555054sec<br> <br> NikiC's example from question body:<br> 0.14452910423279sec<br>
Output for 5.3.8
ircmax's XOR+strspn + ka's loop:<br> 0.1059091091156sec<br> <br> NikiC's example from question body:<br> 0.12735199928284sec<br>
Output for 5.3.7
ircmax's XOR+strspn + ka's loop:<br> 0.083964824676514sec<br> <br> NikiC's example from question body:<br> 0.1331570148468sec<br>
Output for 5.3.6
ircmax's XOR+strspn + ka's loop:<br> 0.083903789520264sec<br> <br> NikiC's example from question body:<br> 0.12747502326965sec<br>
Output for 5.3.5
ircmax's XOR+strspn + ka's loop:<br> 0.1177339553833sec<br> <br> NikiC's example from question body:<br> 0.14934587478638sec<br>
Output for 5.3.4
ircmax's XOR+strspn + ka's loop:<br> 0.083887100219727sec<br> <br> NikiC's example from question body:<br> 0.13388395309448sec<br>
Output for 5.3.3
ircmax's XOR+strspn + ka's loop:<br> 0.087471961975098sec<br> <br> NikiC's example from question body:<br> 0.13411998748779sec<br>
Output for 5.3.2
ircmax's XOR+strspn + ka's loop:<br> 0.10266613960266sec<br> <br> NikiC's example from question body:<br> 0.12879610061646sec<br>
Output for 5.3.1
ircmax's XOR+strspn + ka's loop:<br> 0.1026611328125sec<br> <br> NikiC's example from question body:<br> 0.12566900253296sec<br>
Output for 5.3.0
ircmax's XOR+strspn + ka's loop:<br> 0.081192970275879sec<br> <br> NikiC's example from question body:<br> 0.12148094177246sec<br>
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_CONST in /in/X0Sif on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_CONST in /in/X0Sif on line 6
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/X0Sif on line 6
Process exited with code 255.