NAME
Linux::libperf::Simple - simple wrapper around libperf
SYNOPSIS
use Linux::libperf::Simple;
my $p = Linux::libperf::Simple->new;
$p->enable;
# perform in-process task to measure
$p->disable;
my $result = $p->results;
DESCRIPTION
This module is a simple wrapper around Linux libperf.
It is intended for use in measuring in-process execution time for precise benchmarking, whether it will actually be useful for that remains to be seen.
You will need to install the package (Redhat-ish) or build from source (Debian-ish at this time). libperf is supplied as part of the Linux source tree, it is not theonewolf/libperf
from Github.
To build from source extract the linux sources, the more recent the better:
cd tools/lib/perf
make prefix=/where/to/install install
To actually use this module you will either need to be root, or kernel.perf_event_paranoid
may need to be set to a lower value than the default, look this up before using it.
METHODS
- new()
-
Create a new object, no parameters (yet).
- enable()
- disable()
-
Enable or disable stats collection.
You can enable and disable multiple times. Statistics are cumulative.
- results()
-
Returns a hash reference where the keys are (intended to be) the keys used by the
perf
tool, and the values are each a hash ref with the following possible keys (some are currently never used):val - the value of the captured statistic
enabled
id
lost
run
EXPORTABLE FUNCTIONS
- run(CODEREF)
-
use Linux::libperf::Simple "run"; my $results = run(sub { code to check });
Run CODEREF and returning the timing from running it. Returns a hashref as per results() above.
- report(CODEREF)
-
use Linux::libperf::Simple "report"; report(sub { code to check });
Run CODEREF and produces a simple report to standard output.
BUGS
Everything is subject to change.
AUTHOR
Tony Cook <tony@develop-help.com>