first commit
This commit is contained in:
1
Swoft_BackEndApi/app/Console/.pydio
Normal file
1
Swoft_BackEndApi/app/Console/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
9b3da84a-ca48-45d1-a1cf-2f4787f943c2
|
||||
1
Swoft_BackEndApi/app/Console/Command/.pydio
Normal file
1
Swoft_BackEndApi/app/Console/Command/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
d83e73ef-1861-42a2-b617-46fb98373d97
|
||||
28
Swoft_BackEndApi/app/Console/Command/DemoCommand.php
Normal file
28
Swoft_BackEndApi/app/Console/Command/DemoCommand.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Console\Command;
|
||||
|
||||
use Swoft\Console\Annotation\Mapping\Command;
|
||||
use Swoft\Console\Annotation\Mapping\CommandMapping;
|
||||
use Swoft\Console\Helper\Show;
|
||||
use Swoft\Console\Input\Input;
|
||||
|
||||
/**
|
||||
* Class DemoCommand
|
||||
*
|
||||
* @Command()
|
||||
*/
|
||||
class DemoCommand
|
||||
{
|
||||
/**
|
||||
* @CommandMapping()
|
||||
* @param Input $input
|
||||
*/
|
||||
public function test(Input $input): void
|
||||
{
|
||||
Show::prettyJSON([
|
||||
'args' => $input->getArgs(),
|
||||
'opts' => $input->getOptions(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
107
Swoft_BackEndApi/app/Console/Command/TestCommand.php
Normal file
107
Swoft_BackEndApi/app/Console/Command/TestCommand.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
|
||||
namespace App\Console\Command;
|
||||
|
||||
use Swoft\Console\Annotation\Mapping\Command;
|
||||
use Swoft\Console\Annotation\Mapping\CommandMapping;
|
||||
use function input;
|
||||
use function output;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* Class TestCommand
|
||||
*
|
||||
* @since 2.0
|
||||
*
|
||||
* @Command(name="test",coroutine=false)
|
||||
*/
|
||||
class TestCommand
|
||||
{
|
||||
/**
|
||||
* @CommandMapping(name="ab")
|
||||
*/
|
||||
public function ab()
|
||||
{
|
||||
$type = input()->get('type', '');
|
||||
$uris = $this->uris();
|
||||
|
||||
// Format data
|
||||
if (empty($type)) {
|
||||
$exeUris = [];
|
||||
foreach ($uris as $name => $uriAry) {
|
||||
$exeUris = array_merge($exeUris, $uriAry);
|
||||
}
|
||||
} else {
|
||||
$exeUris = $uris[$type] ?? [];
|
||||
}
|
||||
|
||||
foreach ($exeUris as $uri) {
|
||||
$curlResult = null;
|
||||
$abShell = sprintf('ab -k -n 10000 -c 2000 127.0.0.1:18306%s', $uri);
|
||||
$curlShell = sprintf('curl 127.0.0.1:18306%s', $uri);
|
||||
|
||||
exec($curlShell, $curlResult);
|
||||
output()->writeln('执行结果:' . json_encode($curlResult));
|
||||
output()->writeln('执行URL:' . $abShell . PHP_EOL);
|
||||
|
||||
exec($abShell, $abResult);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function uris(): array
|
||||
{
|
||||
return [
|
||||
'redis' => [
|
||||
'/redis/str',
|
||||
'/redis/et',
|
||||
'/redis/ep',
|
||||
'/redis/release',
|
||||
'/redis/poolSet',
|
||||
],
|
||||
'log' => [
|
||||
'/log/test'
|
||||
],
|
||||
'db' => [
|
||||
'/dbTransaction/ts',
|
||||
'/dbTransaction/cm',
|
||||
'/dbTransaction/rl',
|
||||
'/dbTransaction/ts2',
|
||||
'/dbTransaction/cm2',
|
||||
'/dbTransaction/rl2',
|
||||
'/dbTransaction/multiPool',
|
||||
'/dbModel/find',
|
||||
'/dbModel/update',
|
||||
'/dbModel/delete',
|
||||
'/dbModel/save',
|
||||
'/selectDb/modelNotExistDb',
|
||||
'/selectDb/queryNotExistDb',
|
||||
'/selectDb/dbNotExistDb',
|
||||
'/selectDb/modelDb',
|
||||
'/selectDb/queryDb',
|
||||
'/selectDb/dbDb',
|
||||
'/selectDb/select'
|
||||
],
|
||||
'task' => [
|
||||
'/task/getListByCo',
|
||||
'/task/deleteByCo',
|
||||
'/task/getListByAsync',
|
||||
'/task/deleteByAsync',
|
||||
],
|
||||
'rpc' => [
|
||||
'/rpc/getList',
|
||||
'/rpc/returnBool',
|
||||
'/rpc/bigString',
|
||||
],
|
||||
'co' => [
|
||||
'/co/multi'
|
||||
],
|
||||
'bean' => [
|
||||
'/bean/request'
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user