1#!/usr/bin/env perl 2# 3# Copyright 2017, Data61 4# Commonwealth Scientific and Industrial Research Organisation (CSIRO) 5# ABN 41 687 119 230. 6# 7# This software may be distributed and modified according to the terms of 8# the BSD 2-Clause license. Note that NO WARRANTY is provided. 9# See "LICENSE_BSD2.txt" for details. 10# 11# @TAG(DATA61_BSD) 12# 13 14use warnings; 15use strict; 16 17my $prio = 98; 18my $order = 0; 19my $length = 0; 20my %state = (); 21 22my @overhead = (); 23 24my $run_length = 10000; 25 26#initial run is the calibration loop 27exit -1 if not (<> =~ m/^Processing set 0\.\.\./); #match the first set 28exit -1 if not (<> =~ m/^\s*(.*):\s+(\d+), (\d+), (\d+)/); #match its only member 29@overhead = ($2, $3, $4); 30exit -1 if not ($1 =~ m/measure_bench_overhead/); #make sure it's a bench overhead measurement 31@overhead = map { int($_ / $run_length) } @overhead; 32print "overhead = "; 33print join ", ", @overhead; 34print "\n"; 35 36#process IPC data 37while (<>) { 38 if (m/^Processing set \d+\.\.\./) { 39 $prio = 98; 40 $order = 0; 41 $length = 0; 42 %state = (); 43 printf "\n$prio %s 100, Length %d:\n", $order ? "<-" : "->", $length; 44 next; 45 } 46 elsif (m/^\s*(.*):\s+(\d+), (\d+), (\d+)/) { 47 if (exists $state{$1}) { #we've come across a state we've seen before -- reset 48 %state = (); 49 $state{$1} = 1; 50 51 if ($length == 10) { 52 if($order == 1) { 53 $prio++; 54 $order = 0; 55 $length = 0; 56 } else { 57 $order++; 58 $length = 0; 59 } 60 } else { 61 $length++; 62 } 63 64 printf "\n$prio %s 100, Length %d:\n", $order ? "<-" : "->", $length; 65 } else { 66 $state{$1} = 1; 67 } 68 printf " $1:\n"; 69 printf " CCNT: %d\n", int( ($2 - (2 * $overhead[0]))/$run_length ); 70 printf " PMC0: %d\n", int( ($3 - (2 * $overhead[1]))/$run_length ); 71 printf " PMC1: %d\n", int( ($4 - (2 * $overhead[2]))/$run_length ); 72 } 73 else { 74 print STDERR "invalid line: "; 75 print STDERR; 76 } 77} 78