Last active
April 5, 2021 21:03
-
-
Save vudaltsov/bc484daa7237c9f7f20c4537f07ac60d to your computer and use it in GitHub Desktop.
sqlite vs vimeo/php-mysql-engine
This file contains hidden or 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 | |
declare(strict_types=1); | |
require_once __DIR__.'/vendor/autoload.php'; | |
const ITERATIONS = 10_000; | |
$stopwatch = new \Symfony\Component\Stopwatch\Stopwatch(); | |
$event = $stopwatch->start('db'); | |
$sqlite = new PDO('sqlite::memory:'); | |
$sqlite->exec('create table client(client_id int primary key not null, name text not null)'); | |
for ($i = 1; $i <= ITERATIONS; ++$i) { | |
$sqlite | |
->prepare('insert into client (client_id, name) values (:client_id, :name)') | |
->execute([ | |
'client_id' => $i, | |
'name' => "client {$i}", | |
]) | |
; | |
} | |
$event->lap(); | |
$vimeoMysqlEngine = new \Vimeo\MysqlEngine\Php8\FakePdo('mysql:host=localhost;dbname=testdb;'); | |
$vimeoMysqlEngine->exec('create table client(client_id int primary key not null, name text not null) character set utf8 collate utf8_general_ci'); | |
for ($i = 1; $i <= ITERATIONS; ++$i) { | |
$vimeoMysqlEngine | |
->prepare('insert into client (client_id, name) values (?, ?)') | |
->execute([ | |
1 => $i, | |
2 => "client {$i}", | |
]) | |
; | |
} | |
$event->stop(); | |
echo ' sqlite: '.$event->getPeriods()[0].PHP_EOL; | |
echo 'php-mysql-engine: '.$event->getPeriods()[1].PHP_EOL; |
This file contains hidden or 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
composer req --dev vimeo/php-mysql-engine symfony/stopwatch | |
php test.php | |
# sqlite: 4.00 MiB - 66 ms | |
# php-mysql-engine: 10.00 MiB - 330 ms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment