#! perl -slw use strict; use Statistics::Frequency; use My::Stats::Freq; use Data::Dumper; use Benchmark qw( cmpthese ); my @data_small = qw( bob tom ); my @data_bigger = (qw[bob bob bob tom sally jim bob bob bob tom sally jim]) x 100; cmpthese( 1, { msf_small => \&msf_small, sf_small => \&sf_small, }); cmpthese( -1, { msf_bigger => \&msf_bigger, sf_bigger => \&sf_bigger, }); sub sf_small { my $f = Statistics::Frequency->new( @data_small ); my %f = reverse $f->frequencies; warn "sf broken" unless $f{$f->frequencies_max} eq 'bob'; } sub sf_bigger { my $f = Statistics::Frequency->new( @data_bigger ); my %f = reverse $f->frequencies; warn "sf broken" unless $f{$f->frequencies_max} eq 'bob'; } sub msf_small { my $f = My::Stats::Freq->new( @data_small ); my @max = $f->by_frequency( $f->max() ); warn "msf broken" unless "@max" eq 'tom bob'; } sub msf_bigger { my $f = My::Stats::Freq->new( @data_bigger ); my ($max) = $f->by_frequency( $f->max() ); warn "msf broken" unless $max eq 'bob'; }