Skip to content

Instantly share code, notes, and snippets.

@kandy
Created July 28, 2022 17:57
Show Gist options
  • Save kandy/d0d4907c0d653839f7b78cc0f64faf14 to your computer and use it in GitHub Desktop.
Save kandy/d0d4907c0d653839f7b78cc0f64faf14 to your computer and use it in GitHub Desktop.
<?php
namespace Co;
if (!function_exists('go')) {
function go($f) { $f(); }
function run($f) { $f(); }
} else {
\Co::set(['hook_flags' => SWOOLE_HOOK_TCP]);
}
echo "Start time: ", date(DATE_ATOM), PHP_EOL;
run(function() {
foreach (range(0,30) as $line) {
go(function () {
$pdo = new \PDO(
"mysql:host=db;dbname=magento2",
'root',
'root'
);
return $pdo->query('select sleep(1)')->fetch();
});
}
});
echo "End time: ", date(DATE_ATOM), PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment