define( 'RESULT', [ -1 => '<', 0 => '=', 1 => '>' ] );
$str = str_repeat( 'test,', 25000 );
for ( $t = 0; $t < 5; $t++ ) {
$s = microtime( true );
for ( $i = 0; $i < 10000; $i++ )
$r = count( explode( ',', $str ) );
$e = microtime( true );
echo 'Explode = ' . ( $t1 = $e - $s ) . ' sec' . PHP_EOL;
$s = microtime( true );
for ( $i = 0; $i < 10000; $i++ )
$r = preg_match_all( '/[^,]+/', $str );
$e = microtime( true );
echo 'RegExp = ' . ( $t2 = $e - $s ) . ' sec' . PHP_EOL;
echo 'Explode ' . RESULT[ $t1 <=> $t2 ] . ' RegExp' . PHP_EOL . PHP_EOL;
}
Explode = 9.4393820762634 sec
RegExp = 7.8735761642456 sec
Explode > RegExp
map $limit_bots $myport {
default "upstream_users";
1 "upstream_bots";
}
upstream upstream_users {
server https://.....:3333
}
upstream upstream_bots {
server https://.....:4444
}