3v4l.org

run code in 300+ PHP versions simultaneously
<?php class X { protected $val = []; function notempty() { return ! empty( $this->val ); } function booltest() { return (bool) $this->val; } } $its = 1e3; $x = new X; $t = hrtime(true); for ($i=0;$i++<$its;) $x->notempty(); echo (hrtime(true)-$t)/1e9,"s\n"; $t = hrtime(true); for ($i=0;$i++<$its;) $x->booltest(); echo (hrtime(true)-$t)/1e9,"s\n"; echo "\n=== Warmed up ===\n\n"; $its = 1e5; $t = hrtime(true); for ($i=0;$i++<$its;) $x->notempty(); echo 'notempty: ', $a=(hrtime(true)-$t)/1e9,"s\n"; $t = hrtime(true); for ($i=0;$i++<$its;) $x->booltest(); echo 'bool : ', $b=(hrtime(true)-$t)/1e9,"s\n"; echo 'bool is ', number_format((($a-$b)/$a) * 100, 2 ), "% faster than notempty chain\n";
Output for git.master
2.5118E-5s 2.3165E-5s === Warmed up === notempty: 0.001851377s bool : 0.001587128s bool is 14.27% faster than notempty chain
Output for git.master_jit
2.1932E-5s 2.3145E-5s === Warmed up === notempty: 0.00189985s bool : 0.001540518s bool is 18.91% faster than notempty chain
Output for rfc.property-hooks
2.0811E-5s 1.5593E-5s === Warmed up === notempty: 0.001766458s bool : 0.001468551s bool is 16.86% faster than notempty chain

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
82.37 ms | 408 KiB | 5 Q