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; 32 33print "Priority,Length,Benchmark,CCNT,PMC0,PMC1\n"; 34 35#process IPC data 36while (<>) { 37 if (m/^Processing set \d+\.\.\./) { 38 $prio = 98; 39 $order = 0; 40 $length = 0; 41 %state = (); 42 next; 43 } 44 elsif (m/^\s*(.*):\s+(\d+), (\d+), (\d+)/) { 45 if (exists $state{$1}) { #we've come across a state we've seen before -- reset 46 %state = (); 47 $state{$1} = 1; 48 49 if ($length == 10) { 50 if($order == 1) { 51 $prio++; 52 $order = 0; 53 $length = 0; 54 } else { 55 $order++; 56 $length = 0; 57 } 58 } else { 59 $length++; 60 } 61 } else { 62 $state{$1} = 1; 63 } 64 65 printf "$prio %s 100,%d,$1,%d,%d,%d\n", $order ? "<-" : "->", $length, int( ($2 - (2 * $overhead[0]))/$run_length ), int( ($3 - (2 * $overhead[1]))/$run_length ), int( ($4 - (2 * $overhead[2]))/$run_length ); 66 } 67 else { 68 print STDERR "invalid line: "; 69 print STDERR; 70 } 71} 72