Mercurial > pub > Impl
diff _test/temp.pl @ 412:30e8c6a74937 ref20150831
working on di container (role based registrations)
author | cin |
---|---|
date | Mon, 21 Sep 2015 19:54:10 +0300 |
parents | ee36115f6a34 |
children | ec6f2d389d1e |
line wrap: on
line diff
--- a/_test/temp.pl Mon Sep 21 00:53:10 2015 +0300 +++ b/_test/temp.pl Mon Sep 21 19:54:10 2015 +0300 @@ -1,9 +1,48 @@ #!/usr/bin/perl use strict; +use Carp; +use Time::HiRes qw(gettimeofday tv_interval); +use Scalar::Util qw(blessed); +my $slot; +my $ref = bless \$slot, 'Wrapper'; +sub is { + my $slot = shift; + bless \$slot, 'Wrapper'; +} -use IMPL::require { ServicesBag => 'IMPL::Config::ServicesBag' }; +sub instanceOf { + carp "A typename can't be undefined" unless $_[1]; + blessed($_[0]) and $_[0]->isa($_[1]) +} + +my $bar = Bar->new(); + +my $t = [gettimeofday]; -my $root = ServicesBag->new(); +for(my $i =0; $i< 1000000; $i++) { + is($bar)->instanceOf('Bar'); +} + +print "Is: ",tv_interval($t,[gettimeofday]),"\n"; + +$t = [gettimeofday]; + +for(my $i =0; $i< 1000000; $i++) { + instanceOf($bar, 'Bar'); +} + +print "Is: ",tv_interval($t,[gettimeofday]),"\n"; +package Wrapper; +use Scalar::Util qw(blessed); +sub instanceOf { + blessed(${$_[0]}) and ${$_[0]}->isa($_[1]); +} + +package Bar; +use IMPL::declare { + base => ['IMPL::Object' => undef] +}; + 1;