#!/usr/bin/perl

# Calculates the difference between two profiles (e.g. baseline vs measurement)
# 	from readprofile output
# (c) 2003 Randolph Chung <tausq@debian.org> GPLv2

die "Usage: $0 <before> <after>\n" if ($#ARGV < 1);

foreach $f (shift, shift) {
	open (F, "<$f") || die "$f: $!";
	while (<F>) {
		($d, $cnt, $sym, $t) = split /\s+/;
		next if ($cnt eq "total");
		$count{$sym} = $cnt - $count{$sym};
		$time{$sym} = $t - $time{$sym};
	}
	close F;
}

foreach $sym (sort { $time{$b} <=> $time{$a} } keys(%time)) {
	printf "%6d %-30s %f\n", $count{$sym}, $sym, $time{$sym};
}
