Skip to content

Tool to find lines eliminated by OpCache's bytecode optimizer

License

Notifications You must be signed in to change notification settings

sebastianbergmann/foal

Repository files navigation

No Maintenance Intended CI Status codecov

Find Optimized-Away Lines (FOAL)

foal finds lines of code that are eliminated by OpCache's bytecode optimizer.

Installation

The recommended way to use this tool is a PHP Archive (PHAR):

$ wget https://phar.phpunit.de/foal.phar

$ php foal.phar --version

Furthermore, it is recommended to use Phive for installing and updating the tool dependencies of your project.

Usage

example.php

<?php declare(strict_types=1);
function f()
{
    $result = 'result';

    return $result;
}

Default Output

$ php foal.phar example.php
foal 0.4.0 by Sebastian Bergmann.

  1      <?php declare(strict_types=1);
  2      function f()
  3      {
- 4          $result = 'result';
  5      
  6          return $result;
- 7      }

Lines prefixed with - were optimized away by the OpCache bytecode optimizer.

Graph Output

$ php foal.phar --paths example example/source.php             
foal 0.4.0 by Sebastian Bergmann.

Wrote execution paths for example/source.php to example/unoptimized.dot
Wrote optimized execution paths for example/source.php to example/optimized.dot
$ dot -Tsvg -o example/unoptimized.svg example/unoptimized.dot
$ dot -Tsvg -o example/optimized.svg example/optimized.dot
Before Bytecode Optimization After Bytecode Optimization
unoptimized optimized

About

Tool to find lines eliminated by OpCache's bytecode optimizer

Resources

License

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Languages