#!/usr/bin/perl
use Time::HiRes qw(gettimeofday);

#
#This needs the CPAN module added to the collection...
#
#Time::HiRes, that is
#
#you can use this perl script to time stuff...
#it's fairly sensitive, is it microseconds or something..
#
#Use it like this: Put all your commands in a file, eg 'commandlist'
#invoke like so: perl timecommands.pl commandlist
#
#Careful what's in the file- it'll run it without checking. So don't type
#in rm -rf * unless you meant to do it. 


foreach $file (@ARGV) {
	if(!open(INPUT,"<$file")){
		print STDERR "Can't open input file $file\n";
		next;
	}
	while($input=<INPUT>){
		$time=sprintf("%d%06d", gettimeofday());
		`$input`;
		$time2=sprintf("%d%06d", gettimeofday());
		$time3=$time2-$time;
		print "Time taken for $input : $time2-$time=$time3 microseconds\n";	
	}
	close INPUT;

}
