benchmarks
This commit is contained in:
parent
e748bb20e4
commit
18f192ed65
12 changed files with 1504 additions and 706 deletions
|
@ -482,7 +482,6 @@ App::post('/v1/functions/:functionId/deployments')
|
|||
// Save to storage
|
||||
$fileSize ??= $deviceLocal->getFileSize($fileTmpName);
|
||||
$path = $deviceFunctions->getPath($deploymentId . '.' . \pathinfo($fileName, PATHINFO_EXTENSION));
|
||||
|
||||
$deployment = $dbForProject->getDocument('deployments', $deploymentId);
|
||||
|
||||
$metadata = ['content_type' => $deviceLocal->getFileMimeType($fileTmpName)];
|
||||
|
@ -1002,6 +1001,7 @@ App::post('/v1/functions/:functionId/executions')
|
|||
->addMetric('executions.compute', (int)($executionResponse['duration'] * 1000))// per project
|
||||
->addMetric("{$function->getId()}" . ".executions.compute", (int)($executionResponse['duration'] * 1000))// per function
|
||||
;
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
$interval = (new \DateTime())->diff(new \DateTime($execution->getCreatedAt()));
|
||||
$execution
|
||||
|
|
|
@ -186,7 +186,7 @@ $databaseListener = function (string $event, array $args, Document $project, Usa
|
|||
break;
|
||||
}
|
||||
} catch (Throwable $error) {
|
||||
if (!empty($logger) && $error->getCode() === 500) {
|
||||
if (!empty($logger)) {
|
||||
$log = new Log();
|
||||
$isProduction = App::getEnv('_APP_ENV', 'development') === 'production';
|
||||
$log
|
||||
|
@ -552,7 +552,8 @@ App::shutdown()
|
|||
}
|
||||
|
||||
if (
|
||||
$project->getId() !== 'console' && $mode !== APP_MODE_ADMIN
|
||||
$project->getId() !== 'console'
|
||||
//&& $mode !== APP_MODE_ADMIN
|
||||
) {
|
||||
$fileSize = 0;
|
||||
$file = $request->getFiles('file');
|
||||
|
|
|
@ -59,4 +59,4 @@ App::init()
|
|||
throw new Exception(Exception::USER_AUTH_METHOD_UNSUPPORTED, 'Unsupported authentication route');
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -54,7 +54,7 @@ $server
|
|||
Timer::tick(3000, function () use ($register, $cache, $pools, $periods, &$stats) {
|
||||
$slice = array_slice($stats, 0, count($stats));
|
||||
array_splice($stats, 0, count($stats));
|
||||
$log = [];
|
||||
//$log = [];
|
||||
|
||||
foreach ($slice as $metric) {
|
||||
if ($metric['value'] == 0) {
|
||||
|
@ -100,14 +100,14 @@ $server
|
|||
}
|
||||
}
|
||||
|
||||
$log[] = [
|
||||
'id' => $id,
|
||||
'period' => $period,
|
||||
'time' => $time,
|
||||
'metric' => $metric['key'],
|
||||
'value' => $metric['value'],
|
||||
'region' => App::getEnv('_APP_REGION', 'default'),
|
||||
];
|
||||
// $log[] = [
|
||||
// 'id' => $id,
|
||||
// 'period' => $period,
|
||||
// 'time' => $time,
|
||||
// 'metric' => $metric['key'],
|
||||
// 'value' => $metric['value'],
|
||||
// 'region' => App::getEnv('_APP_REGION', 'default'),
|
||||
// ];
|
||||
} catch (\Exception $e) {
|
||||
console::error($e->getMessage());
|
||||
} finally {
|
||||
|
@ -115,12 +115,12 @@ $server
|
|||
}
|
||||
}
|
||||
|
||||
if (!empty($log)) {
|
||||
$dbForProject->createDocument('statsLogger', new Document([
|
||||
'time' => DateTime::now(),
|
||||
'metrics' => $log,
|
||||
]));
|
||||
}
|
||||
// if (!empty($log)) {
|
||||
// $dbForProject->createDocument('statsLogger', new Document([
|
||||
// 'time' => DateTime::now(),
|
||||
// 'metrics' => $log,
|
||||
// ]));
|
||||
// }
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -12,7 +12,19 @@
|
|||
"scripts": {
|
||||
"test": "vendor/bin/phpunit",
|
||||
"lint": "vendor/bin/phpcs",
|
||||
"format": "vendor/bin/phpcbf"
|
||||
"format": "vendor/bin/phpcbf",
|
||||
"benchmark": [
|
||||
"Composer\\Config::disableProcessTimeout",
|
||||
"vendor/bin/phpbench run --report=appwrite --"
|
||||
],
|
||||
"benchmark-tag": [
|
||||
"Composer\\Config::disableProcessTimeout",
|
||||
"vendor/bin/phpbench run --report=appwrite --tag=baseline --"
|
||||
],
|
||||
"benchmark-compare": [
|
||||
"Composer\\Config::disableProcessTimeout",
|
||||
"vendor/bin/phpbench run --report=appwrite --ref=baseline --"
|
||||
]
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
@ -24,6 +36,7 @@
|
|||
"psr-4": {
|
||||
"Tests\\E2E\\": "tests/e2e",
|
||||
"Tests\\Unit\\": "tests/unit",
|
||||
"Tests\\Benchmarks\\": "tests/benchmarks",
|
||||
"Appwrite\\Tests\\": "tests/extensions"
|
||||
}
|
||||
},
|
||||
|
@ -63,7 +76,7 @@
|
|||
"utopia-php/logger": "0.3.*",
|
||||
"utopia-php/messaging": "0.1.*",
|
||||
"utopia-php/registry": "0.5.*",
|
||||
"utopia-php/storage": "0.13.*",
|
||||
"utopia-php/storage": "0.13.0",
|
||||
"utopia-php/swoole": "0.5.*",
|
||||
"utopia-php/websocket": "0.1.0",
|
||||
"resque/php-resque": "1.3.6",
|
||||
|
@ -86,7 +99,14 @@
|
|||
"phpunit/phpunit": "9.5.20",
|
||||
"squizlabs/php_codesniffer": "^3.6",
|
||||
"swoole/ide-helper": "4.8.9",
|
||||
"textalk/websocket": "1.5.7"
|
||||
"textalk/websocket": "1.5.7",
|
||||
"phpbench/phpbench": "^1.2",
|
||||
|
||||
"symfony/console": "^5.0",
|
||||
"symfony/filesystem": "^5.0",
|
||||
"symfony/finder": "^5.0",
|
||||
"symfony/options-resolver": "^5.0",
|
||||
"symfony/process": "^5.0"
|
||||
},
|
||||
"provide": {
|
||||
"ext-phpiredis": "*"
|
||||
|
|
2125
composer.lock
generated
2125
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -94,6 +94,7 @@ services:
|
|||
- ./src:/usr/src/code/src
|
||||
- ./dev:/usr/local/dev
|
||||
- ./vendor/utopia-php/database:/usr/src/code/vendor/utopia-php/database
|
||||
- ./vendor/utopia-php/storage:/usr/src/code/vendor/utopia-php/storage
|
||||
depends_on:
|
||||
- mariadb
|
||||
- redis
|
||||
|
|
|
@ -39,7 +39,7 @@ class Usage extends Event
|
|||
public function trigger(): string|bool
|
||||
{
|
||||
$client = new Client($this->queue, $this->connection);
|
||||
|
||||
var_dump('triger');
|
||||
var_dump($this->metrics);
|
||||
|
||||
return $client->enqueue([
|
||||
|
|
|
@ -50,7 +50,7 @@ abstract class Base extends Scope
|
|||
$stderr = '';
|
||||
|
||||
Console::execute(
|
||||
'cd ' . realpath(__DIR__ . "/../../resources/functions/php") . " && \
|
||||
'cd ' . realpath(__DIR__ . "/../../../resources/functions/php") . " && \
|
||||
tar --exclude code.tar.gz -czf code.tar.gz .",
|
||||
'',
|
||||
$stdout,
|
||||
|
@ -60,7 +60,7 @@ abstract class Base extends Scope
|
|||
|
||||
public function createDeployment()
|
||||
{
|
||||
$code = realpath(__DIR__ . '/../../resources/functions/php/code.tar.gz');
|
||||
$code = realpath(__DIR__ . '/../../../resources/functions/php/code.tar.gz');
|
||||
|
||||
$response = $this->client->call(Client::METHOD_POST, '/functions/' . static::$functionId . '/deployments', [
|
||||
'content-type' => 'multipart/form-data',
|
||||
|
|
|
@ -31,7 +31,8 @@ abstract class Base extends Scope
|
|||
Permission::read(Role::user($this->getUser()['$id'])),
|
||||
Permission::write(Role::user($this->getUser()['$id'])),
|
||||
],
|
||||
'file' => new CURLFile(realpath(__DIR__ . '/../../resources/logo.png'), 'image/png', 'logo.png'),
|
||||
|
||||
'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'logo.png'),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -107,7 +108,7 @@ abstract class Base extends Scope
|
|||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
], [
|
||||
'fileId' => ID::unique(),
|
||||
'file' => new CURLFile(realpath(__DIR__ . '/../../resources/logo.png'), 'image/png', 'logo.png'),
|
||||
'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'logo.png'),
|
||||
]);
|
||||
|
||||
static::$fileId = $response['body']['$id'];
|
||||
|
|
|
@ -19,8 +19,8 @@ class UsageTest extends Scope
|
|||
use SideServer;
|
||||
use FunctionsBase;
|
||||
|
||||
const WAIT = 5;
|
||||
const CREATE = 20;
|
||||
private const WAIT = 5;
|
||||
private const CREATE = 20;
|
||||
|
||||
protected string $projectId;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ abstract class Scope extends TestCase
|
|||
*/
|
||||
protected $endpoint = 'http://localhost/v1';
|
||||
|
||||
protected function setUp(): void
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->client = new Client();
|
||||
|
||||
|
@ -30,7 +30,7 @@ abstract class Scope extends TestCase
|
|||
;
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
public function tearDown(): void
|
||||
{
|
||||
$this->client = null;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue