#!/usr/bin/perl
#
# SPEEDUP COMPUTATION
#
# Andrew J. Pounds, Ph.D.
# Department of Chemistry
# Mercer University
# Spring 2020
#
# Given the number of processors in column 1
# (starting with 1 processor) and the runtime in 
# column 2 this Perl script will compute the 
# values for the speedup curve.
#
# usage is ./speedup.pl datafile
#
#
use strict;
use warnings;

#Take the name of the variogram file list on input

my $filename = $ARGV[0];

open my $fh, '<', $filename or die "Cannot open $filename: $!";

my @processors;
my @runtimes;

while ( my $line = <$fh> ) {
            print $line;
            chomp($line);
            my @row = split( " ", $line );
                push(@processors,$row[0]);
                push(@runtimes, $row[1]);

}

print "Procs" . "\t" . "Time" . "\t" . "Speedup\n"; 
for ( my $i=0; $i<scalar(@processors); $i++ ) {
           print $processors[$i] . "\t" . $runtimes[$i] . "\t" . ($runtimes[0])/($runtimes[$i]) . "\n";
} 
