LoginSignup
6
4

More than 5 years have passed since last update.

Symfony vs PECL: YAMLのパースベンチマークとってみた

Posted at

PECLのパーサーのほうがSymfonyのより、断然早かった。

比較対象

  1. pecl yaml 1.1.0-dev
  2. Symfony Yaml v2.2.0

比較方法

  • PHP 5.4.5
<?php

require_once 'vendor/autoload.php';

$yaml = "foo: 1
bar: 2
baz: 3
";


function bench(callable $target)
{
    $start = microtime(true);

    for ($i = 0; $i < 10000; $i +=1) {
        $target();
    }

    return microtime(true) - $start;
}

$time = bench(function () use ($yaml) {
   yaml_parse($yaml); 
});

echo "yaml_parse(): $time", PHP_EOL;

$time = bench(function () use ($yaml) {
    Symfony\Component\Yaml\Yaml::parse($yaml);
});

echo "Symfony\Component\Yaml\Yaml::parse(): $time", PHP_EOL;

結果

yaml_parse(): 0.13212895393372
Symfony\Component\Yaml\Yaml::parse(): 3.0159339904785
6
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
4