xref: /minix3/minix/commands/profile/tools/proftsc.pl (revision 433d6423c39e34ec4b79c950597bb2d236f886be)
1*433d6423SLionel Sambuc#!/usr/local/bin/perl
2*433d6423SLionel Sambuc
3*433d6423SLionel Sambuc$SAMPLE_SZ = 8;
4*433d6423SLionel Sambuc
5*433d6423SLionel Sambuc$file = shift;
6*433d6423SLionel Sambuc
7*433d6423SLionel Sambucopen (FILE, $file) or die ("Unable to open $file: $!");
8*433d6423SLionel Sambuc
9*433d6423SLionel Sambuc$_ = <FILE>;
10*433d6423SLionel Sambuc
11*433d6423SLionel Sambucuntil (eof(FILE)) {
12*433d6423SLionel Sambuc  read(FILE, $buf, $SAMPLE_SZ) == $SAMPLE_SZ  or die ("Short read.");
13*433d6423SLionel Sambuc  ($high, $low) = unpack("II", $buf);
14*433d6423SLionel Sambuc
15*433d6423SLionel Sambuc  if ($high - $prevhigh == 0) {
16*433d6423SLionel Sambuc	push (@res, $low - $prevlow);
17*433d6423SLionel Sambuc  }
18*433d6423SLionel Sambuc
19*433d6423SLionel Sambuc  $prevhigh = $high;
20*433d6423SLionel Sambuc  $prevlow = $low;
21*433d6423SLionel Sambuc
22*433d6423SLionel Sambuc  #print "$high $low\n";
23*433d6423SLionel Sambuc
24*433d6423SLionel Sambuc#  $pcs{$pc}++ if ($exe eq "kernel");
25*433d6423SLionel Sambuc}
26*433d6423SLionel Sambuc
27*433d6423SLionel Sambucforeach $diff (sort { $a <=> $b } @res) {
28*433d6423SLionel Sambuc	print $diff."\n";
29*433d6423SLionel Sambuc}
30*433d6423SLionel Sambuc
31*433d6423SLionel Sambuc#foreach $pc (sort { $a <=> $b } keys %pcs) {
32*433d6423SLionel Sambuc#	print "$pc $pcs{$pc}\n";
33*433d6423SLionel Sambuc#}
34