Created
December 2, 2017 16:14
-
-
Save sandrokeil/7574741e35ba92bc7a19aad06e35d4b6 to your computer and use it in GitHub Desktop.
vpack benchmark test #1
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 | |
require 'vendor/autoload.php'; | |
use ArangoDb\Vpack; | |
use ProophTest\EventStore\Mock\TestDomainEvent; | |
$payload = [ | |
'key1' => 'value1', | |
'key2' => 2, | |
'key3' => 'some@mail.com', | |
'key4' => 'value4', | |
'key5' => true, | |
'key6' => false, | |
'key7' => 7, | |
]; | |
$start = microtime(true); | |
for ($j = 0; $j < 10; $j++) { | |
for ($i = 0; $i < 100; $i++) { | |
$data = json_encode(TestDomainEvent::with($payload, $i)); | |
} | |
} | |
$end = microtime(true); | |
$time = $end - $start; | |
echo "json_encode: $time s" . PHP_EOL; | |
$start = microtime(true); | |
for ($j = 0; $j < 10; $j++) { | |
for ($i = 0; $i < 100; $i++) { | |
$data = Vpack::fromJson(json_encode(TestDomainEvent::with($payload, $i))); | |
} | |
} | |
$end = microtime(true); | |
$time = $end - $start; | |
echo "Vpack::fromJson: $time s" . PHP_EOL; | |
$start = microtime(true); | |
for ($j = 0; $j < 10; $j++) { | |
for ($i = 0; $i < 100; $i++) { | |
$data = Vpack::fromArray(TestDomainEvent::with($payload, $i)->toArray()); | |
} | |
} | |
$end = microtime(true); | |
$time = $end - $start; | |
echo "Vpack::fromArray: $time s" . PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
some fluctuations: