-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselect-pq-unbuffered.php
52 lines (39 loc) · 1.35 KB
/
select-pq-unbuffered.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
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
* This file is part of the Makise-Co Postgres Client
* World line: 0.571024a
*
* (c) Dmitry K. <[email protected]>
*/
declare(strict_types=1);
require_once dirname(__DIR__) . '/vendor/autoload.php';
require_once 'random_data.php';
use MakiseCo\Postgres\ConnectionConfigBuilder;
use MakiseCo\Postgres\Driver\Pq\PqConnection;
use MakiseCo\SqlCommon\Contracts\ResultSet;
Swoole\Coroutine\run(function () {
$config = (new ConnectionConfigBuilder())
->withHost('127.0.0.1')
->withPort(5434)
->withUser('makise')
->withPassword('el-psy-congroo')
->withDatabase('makise')
->withApplicationName('Makise Postgres Client Benchmark')
->withUnbuffered(true)
->build();
$connection = PqConnection::connect($config);
// seedData($connection);
// preload code
$connection->query('SELECT 1');
$start = microtime(true);
for ($i = 0; $i < 100; $i++) {
/* @var ResultSet $resultSet */
$resultSet = $connection->query('SELECT * FROM test');
while (null !== ($row = $resultSet->fetchAssoc())) {
}
}
$end = microtime(true);
$total = $end - $start;
printf("Execution time for PHP client (Pq, unbuffered): %f secs\n", $total);
printf("Peak memory usage for PHP client (Pq, unbuffered): %.2f kb\n", memory_get_peak_usage() / 1024);
});