1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
use lib '../lib';
use Benchmark;
my @list;
package MyBenchTestFastBasic;
use Class::Std::Fast constructor => 'basic', isa_unsorted => 1;
my %one_of :ATTR(:name<one> :default<()>);
my %two_of :ATTR(:name<two> :default<()>);
my %three_of :ATTR(:name<three> :default<()>);
my %four_of :ATTR(:name<four> :default<()>);
Class::Std::initialize;
1;
package MyBenchTestFast;
use Class::Std::Fast;
my %one_of :ATTR(:name<one> :default<()>);
my %two_of :ATTR(:name<two> :default<()>);
my %three_of :ATTR(:name<three> :default<()>);
my %four_of :ATTR(:name<four> :default<()>);
Class::Std::initialize;
1;
package MyBenchTest;
use Class::Std;
my %one_of :ATTR(:name<one> :default<()>);
my %two_of :ATTR(:name<two> :default<()>);
my %three_of :ATTR(:name<three> :default<()>);
my %four_of :ATTR(:name<four> :default<()>);
Class::Std::initialize;
1;
package MyBenchTestFastCache;
use base qw(MyBenchTest);
use Class::Std::Fast constructor => 'basic', cache => 1, unsorted_isa => 1;
my %one_of :ATTR(:name<one>);
my %two_of :ATTR(:name<two>);
my %three_of :ATTR(:name<three>);
my %four_of :ATTR(:name<four>);
Class::Std::initialize;
1;
package main;
my $n = 100;
my $n = 5;
timethis $n, sub {
for my $class ('MyBenchTestFastBasic') {
push @list, $class->new({ one => 'foo', two => 'bar'}) for (1..5000);
undef @list
};
};
|