Spyc vs. syck: Speedier YAML parsing in PHP
This post is mostly pretty pictures. I just ran some really quick benchmarks on a couple of of the YAML parsing options available for PHP. The blue line is the Spyc YAML library. The green line is the syck PECL extension. The yellow line is a standard PHP
include(), and is on the chart as a reference point.
The first two charts were tested with a fixed file size and a variable number of iterations. The final chart tracks the change in parsing time as file size increases. Each test was run with 100 iterations, and the file size was doubled at each stage.
The pretty pictures
More info than you cared to know
- This is a very informal benchmark. Feel free to supplement it with testing of your own.
- All benchmarks were run on the same Ubuntu 9.04 virtual machine running PHP 5.2.x.
- Tests were run in a Zoop Framework skeleton app (from the upcoming Lunar release), since I had one handy and it’s really easy to deploy.
- The YAML benchmarks on the first two charts consist of loading and parsing a ~160 line file (a YAML dump of the default Zoop skeleton configuration).
- The PHP include benchmark exists only as a reference point. It consists of loading a
var_dump()’d version of the same configuration array used in the YAML tests. This file was included via a standard PHP
- The first two sets of tests were run with 1, 50, 100, 250, and 500 iterations, respectively. The final test was run with 100 iterations and variable file size.