bench.pl - Compare the performance of perl code snippets across multiple perls.
# Basic: run the tests in t/perf/benchmarks against two or # more perls bench.pl [options] perl1[=label1] perl2[=label2] ... # Run bench.pl's own built-in sanity tests bench.pl --action=selftest
By default, bench.pl will run code snippets found in t/perf/benchmarks (or similar) under cachegrind, in order to calculate how many instruction reads, data writes, branches, cache misses, etc. that one execution of the snippet uses. It will run them against two or more perl executables and show how much each test has gotten better or worse.
It is modelled on the perlbench tool, but since it measures instruction reads etc., rather than timings, it is much more precise and reproducible. It is also considerably faster, and is capable or running tests in parallel (with
-j). Rather than displaying a single relative percentage per test/perl combination, it displays values for 13 different measurements, such as instruction reads, conditional branch misses etc.
There are options to write the raw data to a file, and to read it back. This means that you can view the same run data in different views with different selection and sort options.
=label after each perl executable is used in the display output.
What action to perform. The default is grind, which runs the benchmarks using cachegrind as the back end. The only other action at the moment is selftest, which runs some basic sanity checks and produces TAP output.
Only display the overall average, rather than the results for each individual test.
The path of the file which contains the benchmarks (t/perf/benchmarks by default).
Run a single test against one perl and exit with a zero status if the named field is in the specified range; exit 1 otherwise. It will complain if more than one test or perl has been specified. It is intended to be called as part of a bisect run, to determine when something changed. For example,
bench.pl -j 8 --tests=foo --bisect=Ir,100,105 --perlargs=-Ilib \ ./miniperl
might be called from bisect to find when the number of instruction reads for test foo falls outside the range 100..105.
Enable verbose debugging output.
Display only the specified fields; for example,
If only one field is selected, the output is in more compact form.
Optional command-line arguments to pass to cachegrind invocations.
Display basic usage information.
-j N --jobs=N
Run N jobs in parallel (default 1). This determines how many cachegrind process will running at a time, and should generally be set to the number of CPUs available.
Specify which perl column in the output to treat as the 100% norm. It may be a column number (0..N-1) or a perl executable name or label. It defaults to the leftmost column.
Optional command-line arguments to pass to each perl that is run as part of a cachegrind session. For example,
Display raw data counts rather than percentages in the outputs. This allows you to see the exact number of intruction reads, branch misses etc. for each test/perl combination. It also causes the
AVERAGEdisplay per field to be calculated based on the average of each tests's count rather than average of each percentage. This means that tests with very high counts will dominate.
Order the tests in the output based on the value of field in the column perl. The perl value is as per
--norm. For example
bench.pl --sort=Dw:perl-5.20.0 \ perl-5.16.0 perl-5.18.0 perl-5.20.0
-r file --read=file
Read in saved data from a previous
--writerun from the specified file.
JSON::PPto be available.
Specify a subset of tests to run (or in the case of
--read, to display). It may be either a comma-separated list of test names, or a regular expression. For example
Display progress information.
-w file --write=file
Save the raw data to the specified file. It can be read back later with
JSON::PPto be available.