📄 mysqli_connect_and_close.php
字号:
<?PHP$runs = 10000;$times = array( 'Connect TCP/IP success' => 0, 'Connect TCP/IP failure' => 0, 'Connect Socket success' => 0, 'Connect Socket failure' => 0,);$description = 'Connect with mysqli_connect() and close, no query.';$errors = array();$times['Connect TCP/IP success'] = microtime(true);for ($i = 0; $i < $runs; $i++) { if (!$link = @mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { $errors[] = sprintf("'Connect TCP/IP success' failure [original code: %s]", ($flag_original_code) ? 'yes' : 'no'); break; } mysqli_close($link);}$times['Connect TCP/IP success'] = microtime(true) - $times['Connect TCP/IP success'];$times['Connect TCP/IP failure'] = microtime(true);for ($i = 0; $i < $runs; $i++) { if ($link = @mysqli_connect($host, $user, $passwd . '_unknown', $db, $port)) { $errors[] = sprintf("'Connect TCP/IP failure' failure [original code: %s]", ($flag_original_code) ? 'yes' : 'no'); break; } }$times['Connect TCP/IP failure'] = microtime(true) - $times['Connect TCP/IP failure']; $times['Connect Socket success'] = microtime(true);for ($i = 0; $i < $runs; $i++) { if (!$link = @mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { $errors[] = sprintf("'Connect Socket success' failure [original code: %s]", ($flag_original_code) ? 'yes' : 'no'); break; } mysqli_close($link);}$times['Connect Socket success'] = microtime(true) - $times['Connect Socket success'];$times['Connect Socket failure'] = microtime(true);for ($i = 0; $i < $runs; $i++) { if ($link = @mysqli_connect($host, $user, $passwd . '_unknown', $db, $port, $socket)) { $errors[] = sprintf("'Connect Socket failure' failure [original code: %s]", ($flag_original_code) ? 'yes' : 'no'); break; } }$times['Connect Socket failure'] = microtime(true) - $times['Connect Socket failure'];// sort by runtime in descending orderarsort($times);?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -