3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace foo\bar\baz; class ClassA{ public function getClassExplode(){ return explode('\\', static::class)[0]; } public function getClassReflection(){ return (new \ReflectionClass($this))->getShortName(); } public function getClassBasename(){ return basename(str_replace('\\', '/', static::class)); } } $a = new ClassA(); $num = 100000; $rounds = 10; $res = array( "Reflection" => array(), "Basename" => array(), "Explode" => array(), ); for($r = 0; $r < $rounds; $r++){ $start = microtime(true); for($i = 0; $i < $num; $i++){ $a->getClassReflection(); } $end = microtime(true); $res["Reflection"][] = ($end-$start); $start = microtime(true); for($i = 0; $i < $num; $i++){ $a->getClassBasename(); } $end = microtime(true); $res["Basename"][] = ($end-$start); $start = microtime(true); for($i = 0; $i < $num; $i++){ $a->getClassExplode(); } $end = microtime(true); $res["Explode"][] = ($end-$start); } echo "Reflection: ".array_sum($res["Reflection"])/count($res["Reflection"])." s ".$a->getClassReflection()."\n"; echo "Basename: ".array_sum($res["Basename"])/count($res["Basename"])." s ".$a->getClassBasename()."\n"; echo "Explode: ".array_sum($res["Explode"])/count($res["Explode"])." s ".$a->getClassExplode()."\n";

Abusive script

This script was stopped while abusing our resources

Output for 7.4.10
Reflection: 0.026684665679932 s ClassA Basename: 0.096204233169556 s ClassA Explode: 0.024655222892761 s foo
Output for 7.4.9
Reflection: 0.026942992210388 s ClassA Basename: 0.092772030830383 s ClassA Explode: 0.023927569389343 s foo
Output for 7.4.8
Reflection: 0.029861783981323 s ClassA Basename: 0.097786331176758 s ClassA Explode: 0.025522589683533 s foo
Output for 7.4.7
Reflection: 0.036984419822693 s ClassA Basename: 0.12119851112366 s ClassA Explode: 0.032006812095642 s foo
Output for 7.4.6
Reflection: 0.026688933372498 s ClassA Basename: 0.092025542259216 s ClassA Explode: 0.0224773645401 s foo
Output for 7.4.5
Reflection: 0.026019263267517 s ClassA Basename: 0.092161798477173 s ClassA Explode: 0.022183752059937 s foo
Output for 7.4.4
Reflection: 0.035199904441833 s ClassA Basename: 0.11280090808868 s ClassA Explode: 0.030283451080322 s foo
Output for 7.4.3
Reflection: 0.026669216156006 s ClassA Basename: 0.094353985786438 s ClassA Explode: 0.022389554977417 s foo
Output for 7.4.2
Reflection: 0.030912327766418 s ClassA Basename: 0.10579996109009 s ClassA Explode: 0.024598503112793 s foo
Output for 7.4.1
Reflection: 0.027870345115662 s ClassA Basename: 0.095599317550659 s ClassA Explode: 0.022565984725952 s foo
Output for 7.4.0
Reflection: 0.028973412513733 s ClassA Basename: 0.099400019645691 s ClassA Explode: 0.024629592895508 s foo
Output for 7.3.22
Reflection: 0.036179280281067 s ClassA Basename: 0.096601724624634 s ClassA Explode: 0.025630497932434 s foo
Output for 7.3.21
Reflection: 0.03067581653595 s ClassA Basename: 0.086209201812744 s ClassA Explode: 0.02278528213501 s foo
Output for 7.3.20
Reflection: 0.033483266830444 s ClassA Basename: 0.10500710010529 s ClassA Explode: 0.02683699131012 s foo
Output for 7.3.19
Reflection: 0.032090997695923 s ClassA Basename: 0.09164514541626 s ClassA Explode: 0.021698808670044 s foo
Output for 7.3.18
Reflection: 0.03869948387146 s ClassA Basename: 0.093870687484741 s ClassA Explode: 0.028378987312317 s foo
Output for 7.3.17
Reflection: 0.030953621864319 s ClassA Basename: 0.089243841171265 s ClassA Explode: 0.022937726974487 s foo
Output for 7.3.16
Reflection: 0.05124077796936 s ClassA Basename: 0.13250014781952 s ClassA Explode: 0.036682391166687 s foo
Output for 7.3.15
Reflection: 0.037117052078247 s ClassA Basename: 0.098570704460144 s ClassA Explode: 0.026348400115967 s foo
Output for 7.3.14
Reflection: 0.031033897399902 s ClassA Basename: 0.089215278625488 s ClassA Explode: 0.022332262992859 s foo
Output for 7.3.13
Reflection: 0.035229539871216 s ClassA Basename: 0.097477078437805 s ClassA Explode: 0.023937320709229 s foo
Output for 7.3.12
Reflection: 0.031570506095886 s ClassA Basename: 0.091934299468994 s ClassA Explode: 0.022861957550049 s foo
Output for 7.3.11
Reflection: 0.032006549835205 s ClassA Basename: 0.091909170150757 s ClassA Explode: 0.021921229362488 s foo
Output for 7.3.10
Reflection: 0.031637454032898 s ClassA Basename: 0.088674402236938 s ClassA Explode: 0.022812390327454 s foo
Output for 7.3.9
Reflection: 0.031360125541687 s ClassA Basename: 0.092866516113281 s ClassA Explode: 0.022436904907227 s foo
Output for 7.3.8
Reflection: 0.032072401046753 s ClassA Basename: 0.091443181037903 s ClassA Explode: 0.02208833694458 s foo
Output for 7.3.7
Reflection: 0.034897661209106 s ClassA Basename: 0.098860430717468 s ClassA Explode: 0.025757431983948 s foo
Output for 7.3.6
Reflection: 0.032318329811096 s ClassA Basename: 0.094681763648987 s ClassA Explode: 0.023640727996826 s foo
Output for 7.3.5
Reflection: 0.037469983100891 s ClassA Basename: 0.1012012720108 s ClassA Explode: 0.02529149055481 s foo
Output for 7.3.4
Reflection: 0.034923553466797 s ClassA Basename: 0.10164523124695 s ClassA Explode: 0.028078389167786 s foo
Output for 7.3.3
Reflection: 0.035594058036804 s ClassA Basename: 0.099546504020691 s ClassA Explode: 0.02390558719635 s foo
Output for 7.3.2
Reflection: 0.049100923538208 s ClassA Basename: 0.11032838821411 s ClassA Explode: 0.028371262550354 s foo
Output for 7.3.1
Reflection: 0.044026732444763 s ClassA Basename: 0.095713710784912 s ClassA Explode: 0.023390054702759 s foo
Output for 7.3.0
Reflection: 0.05628879070282 s ClassA Basename: 0.13138611316681 s ClassA Explode: 0.036598968505859 s foo
Output for 7.2.33
Reflection: 0.039157652854919 s ClassA Basename: 0.093236327171326 s ClassA Explode: 0.025349926948547 s foo
Output for 7.2.32
Reflection: 0.037321996688843 s ClassA Basename: 0.095171642303467 s ClassA Explode: 0.025437164306641 s foo
Output for 7.2.31
Reflection: 0.041171979904175 s ClassA Basename: 0.094984769821167 s ClassA Explode: 0.025739908218384 s foo
Output for 7.2.30
Reflection: 0.052055501937866 s ClassA Basename: 0.10070760250092 s ClassA Explode: 0.029213953018188 s foo
Output for 7.2.29
Reflection: 0.043049001693726 s ClassA Basename: 0.091852355003357 s ClassA Explode: 0.026785612106323 s foo
Output for 7.2.28
Reflection: 0.042008495330811 s ClassA Basename: 0.098282051086426 s ClassA Explode: 0.02840313911438 s foo
Output for 7.2.27
Reflection: 0.042631411552429 s ClassA Basename: 0.099368929862976 s ClassA Explode: 0.027778816223145 s foo
Output for 7.2.26
Reflection: 0.036169934272766 s ClassA Basename: 0.093072843551636 s ClassA Explode: 0.026636290550232 s foo
Output for 7.2.25
Reflection: 0.037064003944397 s ClassA Basename: 0.091855883598328 s ClassA Explode: 0.026043009757996 s foo
Output for 7.2.24
Reflection: 0.038229370117188 s ClassA Basename: 0.090109348297119 s ClassA Explode: 0.025152325630188 s foo
Output for 7.2.23
Reflection: 0.041014122962952 s ClassA Basename: 0.099356150627136 s ClassA Explode: 0.026132893562317 s foo
Output for 7.2.22
Reflection: 0.047546577453613 s ClassA Basename: 0.10101292133331 s ClassA Explode: 0.030677771568298 s foo
Output for 7.2.21
Reflection: 0.036980080604553 s ClassA Basename: 0.092257404327393 s ClassA Explode: 0.025978660583496 s foo
Output for 7.2.20
Reflection: 0.06137547492981 s ClassA Basename: 0.12416048049927 s ClassA Explode: 0.039537119865417 s foo
Output for 7.2.19
Reflection: 0.054630589485168 s ClassA Basename: 0.10882053375244 s ClassA Explode: 0.036656403541565 s foo
Output for 7.2.18
Reflection: 0.075070714950562 s ClassA Basename: 0.12358460426331 s ClassA Explode: 0.037894177436829 s foo
Output for 7.2.17
Reflection: 0.070061182975769 s ClassA Basename: 0.12028124332428 s ClassA Explode: 0.042166256904602 s foo
Output for 7.2.16
Reflection: 0.041966128349304 s ClassA Basename: 0.090997719764709 s ClassA Explode: 0.027745866775513 s foo
Output for 7.2.15
Reflection: 0.036242532730103 s ClassA Basename: 0.090737438201904 s ClassA Explode: 0.025441312789917 s foo
Output for 7.2.14
Reflection: 0.03926739692688 s ClassA Basename: 0.095375728607178 s ClassA Explode: 0.029465174674988 s foo
Output for 7.2.13
Reflection: 0.040087795257568 s ClassA Basename: 0.092940425872803 s ClassA Explode: 0.026445603370667 s foo
Output for 7.2.12
Reflection: 0.040836191177368 s ClassA Basename: 0.092611527442932 s ClassA Explode: 0.028203678131104 s foo
Output for 7.2.11
Reflection: 0.043878746032715 s ClassA Basename: 0.10511622428894 s ClassA Explode: 0.028865814208984 s foo
Output for 7.1.6, 7.1.10, 7.1.27, 7.2.10

Process exited with code 137.
Output for 7.2.9
Reflection: 0.043898797035217 s ClassA Basename: 0.10189020633698 s ClassA Explode: 0.031524181365967 s foo
Output for 7.2.8
Reflection: 0.057682633399963 s ClassA Basename: 0.1007209777832 s ClassA Explode: 0.029243111610413 s foo
Output for 7.2.7
Reflection: 0.042787265777588 s ClassA Basename: 0.096090650558472 s ClassA Explode: 0.027647185325623 s foo
Output for 7.2.6
Reflection: 0.039740967750549 s ClassA Basename: 0.090094447135925 s ClassA Explode: 0.026037192344666 s foo
Output for 7.2.5
Reflection: 0.038536810874939 s ClassA Basename: 0.092584848403931 s ClassA Explode: 0.027005982398987 s foo
Output for 7.2.4
Reflection: 0.064068865776062 s ClassA Basename: 0.11114654541016 s ClassA Explode: 0.032722783088684 s foo
Output for 7.2.3
Reflection: 0.066525769233704 s ClassA Basename: 0.1191034078598 s ClassA Explode: 0.039828419685364 s foo
Output for 7.2.2
Reflection: 0.043334817886353 s ClassA Basename: 0.10389728546143 s ClassA Explode: 0.027396416664124 s foo
Output for 7.2.1
Reflection: 0.044583225250244 s ClassA Basename: 0.099781036376953 s ClassA Explode: 0.031075406074524 s foo
Output for 7.2.0
Reflection: 0.05886378288269 s ClassA Basename: 0.11505987644196 s ClassA Explode: 0.034288358688354 s foo
Output for 7.1.33
Reflection: 0.041951131820679 s ClassA Basename: 0.10696387290955 s ClassA Explode: 0.030596208572388 s foo
Output for 7.1.32
Reflection: 0.05989978313446 s ClassA Basename: 0.12680225372314 s ClassA Explode: 0.03419086933136 s foo
Output for 7.1.31
Reflection: 0.041906905174255 s ClassA Basename: 0.10028603076935 s ClassA Explode: 0.027601909637451 s foo
Output for 7.1.30
Reflection: 0.055014681816101 s ClassA Basename: 0.10071332454681 s ClassA Explode: 0.025733780860901 s foo
Output for 7.1.29
Reflection: 0.046676898002625 s ClassA Basename: 0.10331861972809 s ClassA Explode: 0.02871470451355 s foo
Output for 7.1.28
Reflection: 0.060597920417786 s ClassA Basename: 0.12435681819916 s ClassA Explode: 0.036951780319214 s foo
Output for 7.1.26
Reflection: 0.044863367080688 s ClassA Basename: 0.096283459663391 s ClassA Explode: 0.028332567214966 s foo
Output for 7.1.25
Reflection: 0.062038445472717 s ClassA Basename: 0.11664052009583 s ClassA Explode: 0.031941437721252 s foo
Output for 7.1.24
Reflection: 0.040606188774109 s ClassA Basename: 0.093146347999573 s ClassA Explode: 0.025672626495361 s foo
Output for 7.1.23
Reflection: 0.044144463539124 s ClassA Basename: 0.10234429836273 s ClassA Explode: 0.026033663749695 s foo
Output for 7.1.22
Reflection: 0.054265475273132 s ClassA Basename: 0.11526815891266 s ClassA Explode: 0.032711482048035 s foo
Output for 7.1.21
Reflection: 0.04379608631134 s ClassA Basename: 0.11267216205597 s ClassA Explode: 0.032919549942017 s foo
Output for 7.1.20
Reflection: 0.040537190437317 s ClassA Basename: 0.10326056480408 s ClassA Explode: 0.025701570510864 s foo
Output for 7.1.19
Reflection: 0.041188311576843 s ClassA Basename: 0.10439183712006 s ClassA Explode: 0.030669808387756 s foo
Output for 7.1.18
Reflection: 0.048988127708435 s ClassA Basename: 0.10900232791901 s ClassA Explode: 0.031829786300659 s foo
Output for 7.1.17
Reflection: 0.041824388504028 s ClassA Basename: 0.1011726140976 s ClassA Explode: 0.030151677131653 s foo
Output for 7.1.16
Reflection: 0.044214534759521 s ClassA Basename: 0.11230690479279 s ClassA Explode: 0.028952860832214 s foo
Output for 7.1.15
Reflection: 0.060230183601379 s ClassA Basename: 0.1338222026825 s ClassA Explode: 0.039744710922241 s foo
Output for 7.1.14
Reflection: 0.040805506706238 s ClassA Basename: 0.096659851074219 s ClassA Explode: 0.02712779045105 s foo
Output for 7.1.13
Reflection: 0.049704051017761 s ClassA Basename: 0.11055507659912 s ClassA Explode: 0.033163785934448 s foo
Output for 7.1.12
Reflection: 0.047162818908691 s ClassA Basename: 0.10574541091919 s ClassA Explode: 0.029324102401733 s foo
Output for 7.1.11
Reflection: 0.045540165901184 s ClassA Basename: 0.10835721492767 s ClassA Explode: 0.031064534187317 s foo
Output for 7.1.9
Reflection: 0.066396164894104 s ClassA Basename: 0.12020988464355 s ClassA Explode: 0.036591601371765 s foo
Output for 7.1.8
Reflection: 0.045927309989929 s ClassA Basename: 0.10335516929626 s ClassA Explode: 0.031045436859131 s foo
Output for 7.1.7
Reflection: 0.047649097442627 s ClassA Basename: 0.10062408447266 s ClassA Explode: 0.033953523635864 s foo
Output for 7.1.5
Reflection: 0.064022088050842 s ClassA Basename: 0.12150368690491 s ClassA Explode: 0.038417506217957 s foo
Output for 7.1.4
Reflection: 0.050357532501221 s ClassA Basename: 0.099689745903015 s ClassA Explode: 0.031122207641602 s foo
Output for 7.1.3
Reflection: 0.041847515106201 s ClassA Basename: 0.097470235824585 s ClassA Explode: 0.024748396873474 s foo
Output for 7.1.2
Reflection: 0.043929505348206 s ClassA Basename: 0.09900438785553 s ClassA Explode: 0.027590036392212 s foo
Output for 7.1.1
Reflection: 0.039497518539429 s ClassA Basename: 0.10110139846802 s ClassA Explode: 0.028096699714661 s foo
Output for 7.1.0
Reflection: 0.055944013595581 s ClassA Basename: 0.10166833400726 s ClassA Explode: 0.030821228027344 s foo