June 08 2015 A Development Tool for Library Code Back

Refactoring: Add Benchmarking

                # get_2_intersection.pl
                use strict;
                use warnings;
                use 5.10.1;
                use Test::More qw( no_plan );
                use Benchmark qw( timethis );
                use lib '/home/jkeenan/gitwork/list-compare/blib/lib';
                use List::Compare::Functional qw( get_intersection );
                my $medium  = [ 1001 ..   4000 ];
                my $small   = [  991 ..   1010 ];
                my ($args, $expect, @int, $seen);
                say "List::Compare::Functional version: ",
                    sprintf("%.5f" => $List::Compare::Functional::VERSION);
                $args   = [ $medium, $small ];
                $expect = { map { $_ => 1 } ( 1001 .. 1010 ) };
                @int    = get_intersection( $args);
                $seen   = { map { $_ => 1} @int };
                is_deeply($seen, $expect, "Got expected intersection");
                timethis( 1_000, sub { get_intersection($args) } );


Home Last TOC Copyright © 2015 James E Keenan Back Next