NAME
LinkedList::Single::Example::Bench - shared timing, memory, and complexity helpers
SYNOPSIS
use FindBin::libs;
use LinkedList::Single::Example::Bench qw( best_of complexity report );
my $secs = best_of 3 => sub { ... };
my $cx = complexity \&Some::Package::method;
DESCRIPTION
Every example in LinkedList::Single::Examples compares a LinkedList::Single solution with the plain-array solution to the same problem. These helpers keep the comparisons the same from one example to the next.
- best_of( $reps, $code )
-
Fastest of
$repsruns of$code, in seconds. - complexity( $code )
-
Deparses
$codeand returns a hashref countingstatements,branches, andindex_ops(element access,$#, andsplice). The last is the position arithmetic that a cursor makes unnecessary. - array_bytes( $aref ), list_bytes( $list )
-
Container overhead in bytes: the array's allocated capacity, which stays at its high-water mark after
shift, versus the sum of the live nodes of the list. - report( $title, @row )
-
Prints a table of rows with
name,secs, optionalbytes, andcx(as returned bycomplexity).