File Input

If your benchmark subject operates on file contents, or can otherwise be parameterized from the contents of files.

Given you have a directory file-input containing a list of files, and each of these files represents a benchmarking scenario:

use Generator;

final class FileInputBench
{
    /**
     * @ParamProviders("provideText")
     */
    public function benchFind(array $params): void
    {
        // do something with $params['text']
    }

    public function provideText(): Generator
    {
        foreach (glob(__DIR__ . '/file-input/*') as $path) {
            yield basename($path) => [
                'text' => file_get_contents($path)
            ];
        }
    }
}

Note that we yield the filename as the key, which is then used as the parameter set name:

\PhpBench\Examples\Benchmark\Pattern\FileInput\FileInputBench

    benchFind # example1....................I9 ✔ Mo0.205μs (±44.54%)
    benchFind # example2....................I9 ✔ Mo0.337μs (±46.15%)