Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
vpack benchmark test #1
<?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;
@sandrokeil

This comment has been minimized.

Copy link
Owner Author

sandrokeil commented Dec 2, 2017

json_encode: 0.30263495445251 s
Vpack::fromJson: 0.43449902534485 s
Vpack::fromArray: 0.35646820068359 s

some fluctuations:

json_encode: 0.29366707801819 s
Vpack::fromJson: 0.3661630153656 s
Vpack::fromArray: 0.33927893638611 s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.