# ********** BridgeDemo.pl **********
use strict;
use Abstraction;
use AbstractionImpl1;
use SpecializedAbstractionA;
use SpecializedImplA1;
use SpecializedAbstractionB;
use SpecializedImplB1;
use AbstractionImpl2;
use SpecializedImplA2;
use SpecializedImplB2;
use Time::HR;

my $t1 = gethrtime();
my $i;
for ($i=0; $i<100000; $i++) {
  # using Impl1 Hierarchy
  my $abs = Abstraction->new(AbstractionImpl1->new());
  $abs->x();
  my $specAbsA = SpecializedAbstractionA->new(SpecializedImplA1->new());
  $specAbsA->x();
  $specAbsA->a();
  my $specAbsB = SpecializedAbstractionB->new(SpecializedImplB1->new());
  $specAbsB->x();
  $specAbsB->b();
  # using Impl2 Hierarchy
  $abs = Abstraction->new(AbstractionImpl2->new());
  $abs->x();
  $specAbsA = SpecializedAbstractionA->new(SpecializedImplA2->new());
  $specAbsA->x();
  $specAbsA->a();
  $specAbsB = SpecializedAbstractionB->new(SpecializedImplB2->new());
  $specAbsB->x();
  $specAbsB->b();
}
my $t2 = gethrtime();
print (int(($t2-$t1)/1000000))." ";
