/
bench.php
35 lines (26 loc) · 892 Bytes
/
bench.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
<?php
require __DIR__ . '/vendor/autoload.php';
$config = require __DIR__ . '/config/config.php';
use ImboClient\ImboClient;
use ImboClient\ImagesQuery;
$client = ImboClient::factory($config);
$query = (new ImagesQuery())->limit($config['numImages']);
$response = $client->getImages($query);
$bytes = [];
$start = time();
$i = 0;
for ($x = 0; $x < $config['iterations']; $x++) {
foreach ($response['images'] as $image) {
$url = $client->getImageUrl($image['imageIdentifier'])
->{$config['transformation']}($config['size'][0], $config['size'][1])
->convert($config['format']);
$bytes[] = strlen($client->getImageDataFromUrl($url));
echo '.';
if (++$i === 50) {
$i = 0;
echo PHP_EOL;
}
}
}
echo PHP_EOL;
echo 'Resized ' . count($bytes) . ' images in ' . (time() - $start) . 's' . PHP_EOL;