#! /usr/bin/perl -w use strict; use lib '/home/httpd/lib'; use Benchmark::Timer; use Quantum::Superpositions; my %methods = ( george_sherston1 => \&m1, george_sherston2 => \&m2, george_sherston3 => \&m3, broquaint => \&m4, abigail => \&m5, ferrency => \&m6, esper => \&m7, samtregar => \&m8, ); my @tabs = ( { Action => 'GetAll', Suppress => 0, }, { Action => 'Make', Suppress => 0, }, { Action => 'MakeOnly', Suppress => 0, }, { Action => 'foo', Suppress => 0, }, { Action => 'bar', Suppress => 0, }, { Action => 'baz', Suppress => 0, }, { Action => 'goom', Suppress => 0, }, { Action => 'gomp', Suppress => 0, }, ); for my $m (sort keys %methods) { my $t = Benchmark::Timer->new(skip => 1); for(0 .. 10000) { $t->start($m); $methods{$m}->(); $t->stop; } $t->report; } sub m1 { for (@tabs) { if ( $_->{Action} eq 'GetAll' or $_->{Action} eq 'Make' or $_->{Action} eq 'MakeOnly' ) { $_->{Suppress} = 1; } } } sub m2 { for my $hash (@tabs) { if (grep {$hash->{Action} eq $_} qw/ GetAll Make MakeOnly /) { $hash->{Suppress} = 1; } } } sub m3 { for (@tabs) { if ($_->{Action} =~ /(^GetAll$)|(^Make$)|(MakeOnly$)/) { $_->{Suppress} = 1; } } } sub m4 { for (@tabs) { if($_->{Action} eq any( qw(GetAll Make MakeOnly) )) { $_->{Suppress} = 1; } } } sub m5 { my %match = map {$_ => 1} qw /GetAll Make MakeOnly/; for (@tabs) { $_-> {Suppress} = 1 if $match {$_-> {Action}}; } } sub m6 { for (@tabs) { $_->{Suppress} ||= $_->{Action} =~ /^(GetAll|Make|MakeOnly)$/; } } sub m7 { my %defaults = (GetAll => 1, Make => 1, MakeOnly => 1); for (@tabs) { $_->{Suppress} = $defaults{$_->{Action}} if exists $defaults{$_->{Action}}; } } sub m8 { my %suppress = map { $_ => 1 } qw(GetAll Make MakeOnly); for (@tabs) { $_->{Suppress} = 1 if exists $suppress{$_}; } }