package main;

  use strict;

# Iterated through the grepped results
my %h = ();
while (<>) {
  my $line = $_;
  $line =~ /results\//;
  $line = $';
  $line =~/t\.(\d+)\.(\d+)\.(\d+)\.(\d+)\.txt.*cputime\s+(\d+)\.(\d+)/;
  my $dbSize = int($1);
  my $testCases = int($2);
  my $testLength = int($3);
  my $run = int($4);
  my $seconds = int($5)*100;
  my $fraction = int($6);
  
  $h{"$dbSize.$testCases.$testLength.$run"} = $seconds + $fraction;
  }

# Global variables
  my @TestSizes = (1, 100, 200, 300, 400, 500);
  #my @TestSizes = (1, 100);
  my @TestLengths = (1, 5, 10, 15, 20, 25, 30, 35);
  #my @TestLengths = (5);
  my @FactSizes = ([5000,2000], [10000, 4000], [15000, 6000], [20000, 8000]);
  #my @FactSizes = ([10000, 4000]);
  my $Runs = 3;
  my $dir = "results";

  foreach my $dbSize (@FactSizes) {
    my ($ad, $sd) = @$dbSize;
    print "$ad\n";
    print join(", ", @TestLengths) . "\n";
    foreach my $testSize (@TestSizes) {
      print "$testSize";
      foreach my $testLength (@TestLengths) {
        my $run = 0;
        my $sum = 0;
        for ($run = 0; $run < $Runs; $run++) {
          $sum += $h{"$ad.$testSize.$testLength.$run"};
          }
        print ", " . int($sum/3);
        }
      print "\n";
      }
    }
