#!/usr/local/bin/perl5 -w
#!/usr/bin/perl

$test_cnt = 5;

for ($i = 1; $i <= $test_cnt; $i++) {
    system("./driver", $i);

if($i == 1){$N= 32;}
if($i == 2){$N= 64;}
if($i == 3){$N= 128;}
if($i == 4){$N= 256;}
if($i == 5){$N= 1024;}


$cache_count = `tail -1 cacheprof.out.summary`;

my (@line) = split(/[,\)]\s+/, $cache_count);

# 1 == reads, 2 == writes, 3 == read misses, 4 == write misses
# We need to eat the trailing ',' in the number.

my ($refs) = $line[1] + $line[2];
my ($hits) = $refs - ($line[3] + $line[4]);

print "Hit score for test $i = " ,  ($line[3] + $line[4])/($N*$N), "\n";




}
