# ********** ObserverDemo.pl **********
use strict;
use Observer1;
use Observable1;
use Time::HR;

my $t1 = gethrtime();
my $i;
my $j;
my $k;
my $observers = [];
my $observables = [];
for ($i=0; $i<500; $i++) {
  $observers->[$i] = Observer1->new();
}
for ($j=0; $j<500; $j++) {
  $observables->[$j] = Observable1->new();
  for ($i=0; $i<500; $i++) {
    $observables->[$j]->addObserver($observers->[$i]);
  }
}
for ($k=0; $k<100; $k++) {
  for ($j=0; $j<500; $j++) {
    $observables->[$j]->setValue($k);
  }
}
my $t2 = gethrtime();
print (int(($t2-$t1)/1000000))." ";
