#!/usr/bin/perl

%syscalls = ();		# clear hash

#
# help sort descending
#
sub des {
	$syscalls{$b} <=> $syscalls{$a};
}

print "SYSCALL                    \tCOUNT\n";

open STREAM, "stap -g topsys_1.stp 2>/dev/null |" or die "can't fork: $!";
while (<STREAM>) {
	($syscall, $cnt) = split(" ", $_);
	$syscalls{$syscall}=$cnt;
}

foreach my $key (sort des (keys (%syscalls)))
{
	print sprintf("%-25s\t%d", $key, $syscalls{$key}) . "\n";
}
close STREAM or die "bad stap: $! $?";

