-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.php
40 lines (31 loc) · 1.08 KB
/
main.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
declare(strict_types=1);
use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem;
use Cache\Adapter\Filesystem\FilesystemCachePool;
require(__DIR__ . '/vendor/autoload.php');
require(__DIR__ . '/../helpers/get-content-ids.php');
$filesystemAdapter = new Local(__DIR__);
$filesystem = new Filesystem($filesystemAdapter);
$filesystemCache = new FilesystemCachePool($filesystem);
$config = \Joystick\ClientConfig::create()
->setApiKey(getenv('JOYSTICK_API_KEY'))
->setSemVer("0.0.1")
->setCacheExpirationSeconds(10)
->setCache($filesystemCache);
$client = \Joystick\Client::create($config);
$numberOfCalls = 1;
$getContents = function () use ($client, &$numberOfCalls) {
$before = microtime(true);
$client->getContents(getContentIdsFromEnv(), [
'serialized' => false,
'fullResponse' => true,
]);
$after = microtime(true);
$roundExecutionTime = number_format($after - $before, 2);
echo "Request #$numberOfCalls is finished in $roundExecutionTime sec\n";
$numberOfCalls++;
};
for ($i = 0; $i < 5; $i++) {
$getContents();
}