Verifying performance improvements

The motivation for implementing the compilation to PHP was to increase the parser's performance. As a last step, we'll now try to verify that the caching layer does actually increase the performance of the parser.

For this, you can use the PHPBench package that you can install using composer:

$ composer require phpbench/phpbench

PHPBench offers a framework for benchmarking single units of code in isolation (in that respect being similar to PHPUnit, only for benchmarks instead of tests). Each benchmark is a PHP class that contains scenarios as methods. The name of each scenario method needs to start with bench.

Start by creating a bench.php file in your root directory with the following contents:

require 'vendor/autoload.php'; ...

Get PHP 7 Programming Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.