Skip to content

Commit

Permalink
added CustomElementButton.php performance test page
Browse files Browse the repository at this point in the history
  • Loading branch information
brainfoolong committed Apr 6, 2024
1 parent 2bccd70 commit 22f86df
Showing 1 changed file with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace Framelix\FramelixTests\View\Misc;

use Framelix\Framelix\Network\JsCall;
use Framelix\Framelix\Utils\JsonUtils;
use Framelix\Framelix\View;

class CustomElementButton extends View\Backend\View
{

protected string|bool $accessRole = "*";

public static function onJsCall(JsCall $jsCall): void
{
if ($jsCall->action === 'more-buttons') {
for ($i = 5000; $i < 10000; $i++) {
?>
<framelix-button icon="718" theme="<?= $i % 2 ? 'error' : 'success' ?>" style="font-family: monospace">
Btn <?= sprintf("%04d", $i) ?>
</framelix-button>
<?php
}
}
}

public function onRequest(): void
{
$this->showContentBasedOnRequestType();
}

public function showContent(): void
{
?>
<h3>Performance Test when displaying 5000 buttons and loading 5000 more dynamically</h3>
<?php
for ($i = 0; $i < 5000; $i++) {
?>
<framelix-button icon="718" theme="<?= $i % 2 ? 'error' : 'success' ?>" style="font-family: monospace">
Btn <?= sprintf("%04d", $i) ?>
</framelix-button>
<?php
}
?>
<div class="results"></div>
<script>
(async function () {
const response = await FramelixRequest.jsCall(<?=JsonUtils::encode(
JsCall::getUrl([self::class, "onJsCall"], "more-buttons")
)?>).getJson()
$('.results')[0].innerHTML = response
})()
</script>
<?php
}

}

0 comments on commit 22f86df

Please sign in to comment.