-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added CustomElementButton.php performance test page
- Loading branch information
1 parent
2bccd70
commit 22f86df
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
appdata/modules/FramelixTests/src/View/Misc/CustomElementButton.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
|
||
} |