Created
February 9, 2024 06:00
-
-
Save martyf/626e47a9f2f26829e08e5af350382dc7 to your computer and use it in GitHub Desktop.
Test Tags to demonstrate the performance gains of using Blink in Statamic
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
<?php | |
namespace App\Tags; | |
use Statamic\Facades\Blink; | |
use Statamic\Tags\Tags; | |
class TagTestBlink extends Tags | |
{ | |
public function index() | |
{ | |
$time_start = microtime(true); | |
if (!Blink::has('expensive')) { | |
// sleep to simulate a slow piece of code | |
sleep(1); | |
// store something to stop it running again | |
Blink::put('expensive', true); | |
} | |
$time_end = microtime(true); | |
return number_format( ($time_end - $time_start), 5); | |
} | |
} |
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
<?php | |
namespace App\Tags; | |
use Statamic\Tags\Tags; | |
class TagTestSlow extends Tags | |
{ | |
public function index() | |
{ | |
$time_start = microtime(true); | |
// sleep to simulate a slow piece of code | |
sleep(1); | |
$time_end = microtime(true); | |
return number_format(($time_end - $time_start), 5); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment