<?php
function str_contains_not( $show = '' ) {
$url = true;
if ( ! str_contains( $show, 'url' )
&& ! str_contains( $show, 'directory' )
&& ! str_contains( $show, 'home' )
) {
$url = false;
}
if ( $url ) {}
}
function str_contains_or( $show = '' ) {
if ( str_contains( $show, 'url' )
|| str_contains( $show, 'directory' )
|| str_contains( $show, 'home' ) ) {}
}
$its = 1e3;
$t = hrtime(true);
for ( $i=0;$i++<$its;)
$z = str_contains_not( 'blogname' );
echo (hrtime(true)-$t)/1e9,"s\n";
$t = hrtime(true);
for ( $i=0;$i++<$its;)
$z = str_contains_or( 'blogname' );
echo (hrtime(true)-$t)/1e9,"s\n";
echo "\n=== Warmed up ===\n\n";
$its = 1e5;
$t = hrtime(true);
for ( $i=0;$i++<$its;)
$z = str_contains_not( 'blogname' );
echo 'str_contains_not: ', $a=(hrtime(true)-$t)/1e9,"s\n";
$t = hrtime(true);
for ( $i=0;$i++<$its;)
$z = str_contains_or( 'blogname' );
echo 'str_contains_or : ', $b=(hrtime(true)-$t)/1e9,"s\n";
echo 'str_contains_or is ', number_format((($a-$b)/$a) * 100, 2 ), "% faster than str_contains_not\n";
preferences:
25.07 ms | 406 KiB | 5 Q